Results 1 to 2 of 2
Thread: Code problem
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Nov 2011
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
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 09:17 PM.
- Join Date
- May 2011
Throw some double quotes around your variables and strings when comparing, e.g.:
if [ "$REPLY" == 'A' ] ... elif [ "$REPLY" == 'B' ]
echo "File Restored" fi