Results 1 to 2 of 2
Hi,
I created a script for use on Mandriva however I've recently changed over to using and Puppy Linux as the OS for my system and I thought that the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-21-2011 #1Just Joined!
- Join Date
- Nov 2011
- Posts
- 1
Code problem
Hi,
I created a script for use on Mandriva however I've recently changed over to using and Puppy Linux as the OS for my system and I thought that the code in my script would be transferable however it seems not to be backing up/restoring, instead it's trying to read. I'll show you my code and explain a little more
Can anyone offer any advice on this problem?Code:if [ $REPLY = A ] then echo -n "Enter the name of the folder to be backed up: " read dir_name until [ -d "$dir_name" ] do echo "Please enter a valid folder name : " read dir_name done echo -n "Enter the Directory name of where you would like it backed up to : " read dir_name2 until [ -d "$dir_name2" ] do echo "Please enter a valid folder name : " read dir_name2 done tar -cvf $dir_name2/ $dir_name echo "Backup Complete" THE CODE BELOW SEEMS TO BE THE PART OF THE CODE THAT ISN'T WORKING elif [ $REPLY = B ] then echo Enter the directory name of where the backup is located : read dir_name2 until [ -d "$dir_name2" ] do echo "Please enter a valid backup name : " read dir_name2 done ls -al $dir_name2 echo -n "Enter the File name to be restored : " read filename until [ -f "$dir_name2/$filename" ] do echo "Please enter a valid filename : " read filename done tar -vxf $dir_name2/$filename echo "File Restored
Thank you in advance.Last edited by Lottie; 11-21-2011 at 08:17 PM.
- 11-22-2011 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,657
Throw some double quotes around your variables and strings when comparing, e.g.:
Also, did you cut the code off when cutting-and-pasting? If not, then you are missing closing double-quotes and a closing FI, e.g.:Code:if [ "$REPLY" == 'A' ] ... elif [ "$REPLY" == 'B' ]
Code:echo "File Restored" fi


Reply With Quote
