Advertisement

07.10.2008 at 04:57AM PDT, ID: 23553383 | Points: 500
[x]
Attachment Details

Looking for some help constructing a shell script

Asked by nappy_d in Bourne-Again Shell (bash), Scripting Languages, Shell Scripting

Tags: ,

I am a complete noob at shell scripting.  I have a business that wants record after hours activity via dgital wifi security camera's due to theft.

I devised a method that would use DCS 5300G IP cameras to upload their data to an off-site location via FTP.

This works but now, I am having some issues with the crontab commands I have setup to create a daily archive of the data via the web hosting company's cPanel.  Unfortunately, the webhosting company's support team is not able to decipher the crontab(so they say) to troubleshoot the issue.

How can I turn this all in to a shell script that can run against each directory of files and perform the same steps outlined below.

I created the following entries:
- 0 9 * * *
this stands for run every day at 9am, based on the server's time

- This command will zip all .jpg files found in the path: /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL

- 0 9 03 * * *
this stands for run every day at 9:03am, based on the server's time

- This command will delete all .jpg files in the path rm /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL

- 0 9 06 * * *
this stands for run every day at 9:06am, based on the server's time

- This command will move the .zip file from the /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL directory to /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

mv /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL/tbs-cam1FL.zip /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

- 0 9 09 * * *
this stands for run every day at 9:09am, based on the server's time

- This command will execute a shell script which will append today's date to the zip file that was moved in the previous step above. This script was tested by one of your techs in this ticket but it is not running properly from my crontab.

sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/addDate.sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/tbs-cam-1FL.zip

- 0 9 12 * * *
this stands for run every day at 9:12am, based on the server's time

- This command will zip all .jpg files found in the path: /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL



- 0 9 15 * * *
this stands for run every day at 9:15am, based on the server's time

- This command will delete all .jpg files in the path rm /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL


- 0 9 18 * * *
this stands for run every day at 9:18am, based on the server's time

- This command will move the .zip file from the /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL directory to /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

mv /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL/tbs-cam2FL.zip /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

- 0 9 21 * * *
this stands for run every day at 9:21am, based on the server's time

- This command will execute a shell script which will append today's date to the zip file that was moved in the previous step above. This script was tested by one of your techs in this ticket but it is not running properly from my crontab.

sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/addDate.sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/tbs-cam-2FL.zip

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
This is the content of the .sh file
 
#! /bin/sh
 
filefullname=$1
filename=${filefullname%.*}
fileext=${filefullname##*.}
 
DATETIME=`date +%Y%m%d`
 
newfilename="${filename}${DATETIME}.${fileext}"
 
mv $filefullname $newfilename
[+][-]07.10.2008 at 06:38AM PDT, ID: 21973242

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 03:57PM PDT, ID: 21978085

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2008 at 06:37AM PDT, ID: 21982226

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.11.2008 at 06:46AM PDT, ID: 21982325

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2008 at 02:49PM PDT, ID: 21986332

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.02.2008 at 03:33PM PDT, ID: 22372356

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.02.2008 at 03:36PM PDT, ID: 22372370

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628