Register
It is currently Tue Jul 22, 2014 9:40 pm

Need some help


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed Jun 25, 2008 6:37 am   

Joined: Wed Jun 25, 2008 6:21 am
Posts: 1
I want to mount a drive and if that is successfull rsync the mounted drive with a local folder
something like the following but I can get the condition part to work correctly.

Code:

if [mount -t smbfs -o username=administrator,password=$PASS //$CLIENT/backup$ /tmp/stage$CLIENT] then

rsync -av --delete /tmp/stage$CLIENT/ /home/userdata/$CLIENT && echo "$CLIENT backup complete at `date +"%D %T"`" > /tmp/$CLIENT.txt

fi




Any help would be appreciated.


Top
 Profile  
 PostPosted: Wed Jun 25, 2008 9:07 am   

Joined: Wed Feb 20, 2008 4:44 pm
Posts: 4
Location: /dev/null
Sort of simple but what about something like.


Code:
mount -t smbfs -o username=administrator,password=$PASS //$CLIENT/backup$ /tmp/stage$CLIENT

if [ $? == "0" ]
then
    rsync -av --delete /tmp/stage$CLIENT/ /home/userdata/$CLIENT && echo "$CLIENT backup complete at `date +"%D %T"`" > /tmp/$CLIENT.txt
else
    echo "Their was an error....Dieing
fi


Top
 Profile  
 PostPosted: Wed Jun 25, 2008 11:28 am   

Joined: Tue Apr 01, 2008 10:19 am
Posts: 49
the "[" and "]" are not part of "if"'s syntax. "[" is a command. "if" runs the command you pass it, and checks that the return code is 0. So your line is trying to run the command "[mount", which does not exist.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP