Im new to this and i was trying to create a script that
allows a user to backup a directory and all the files and directories below it. I was trying to get the program to take exactly two parameters, the name of a source directory (to back up) and a destination directory (to back up to). If the user does not enter exactly two parameters, I wanted the program to output a suitable error messages and exit.
Thought i had it done and dusted but when i run it the following error message appears
syntax error at line 33: `end of file' unexpected" and i havnt a clue how to fix it, and get my script working, any help please?
#!/bin/sh #Path of the shell transient command
if [ "$1 $2" -ne "0" ]; then echo "Sorry, you must enter two parameters exactly"
exit 1
else
if [! -f $1 ]
then
echo "The directory [$1] does not exist - Aborting"
exit
else
'cp -R $1 $2' #Backs up the directories mentioned in the command line
fi
if [ -f $2 ]
then
echo "The directory [$2] already exists"
/usr/5bin/echo "Do you want to overwrite the directory? ( y/n ) :\c"
read answer
read $answer
echo ""
if [ "£answer"!= "y" ] && [ "$answer"!= "Y" ]
then
echo "Aborting"
exit
fi
fi
fi
allows a user to backup a directory and all the files and directories below it. I was trying to get the program to take exactly two parameters, the name of a source directory (to back up) and a destination directory (to back up to). If the user does not enter exactly two parameters, I wanted the program to output a suitable error messages and exit.
Thought i had it done and dusted but when i run it the following error message appears
syntax error at line 33: `end of file' unexpected" and i havnt a clue how to fix it, and get my script working, any help please?
#!/bin/sh #Path of the shell transient command
if [ "$1 $2" -ne "0" ]; then echo "Sorry, you must enter two parameters exactly"
exit 1
else
if [! -f $1 ]
then
echo "The directory [$1] does not exist - Aborting"
exit
else
'cp -R $1 $2' #Backs up the directories mentioned in the command line
fi
if [ -f $2 ]
then
echo "The directory [$2] already exists"
/usr/5bin/echo "Do you want to overwrite the directory? ( y/n ) :\c"
read answer
read $answer
echo ""
if [ "£answer"!= "y" ] && [ "$answer"!= "Y" ]
then
echo "Aborting"
exit
fi
fi
fi