hey guys, im very new to shell programming and ive been experimating the whole day.
sadly im stuck now with my code:
#!/bin/bash
function doCheck() {
function doTestCopy() {
file="./test.sh"
if [ -e "$file" ]; then
echo "$file exists"
else
echo "$file doesnt exist..creating now"
if eval "touch test.sh"
then
echo "$file successfully created"
else
echo "$file creation failed."
fi
fi
#test1.sh
#short sample for checking file test1.sh
file2="./test1.sh"
if [ -e "$file2" ]; then
echo "$file2 exists"
else
echo "$file2 doesnt exist..creating now"
if eval "touch test1.sh"
then
echo "$file2 successfully created."
else
echo "creation just failed."
echo "anything else?"
fi
fi
#testfolder
#short sample for checking folder testfolder
folder="testfolder"
if [ -d "$testfolder" ]; then
echo "$folder exists"
else
echo "$folder doesnt exist..creating now"
if eval "mkdir "testfolder""
then
echo "$folder successfully created."
else
echo "creation just failed ."
fi
fi
#random file create and copy
rf="./randomfile.sh"
if [ -e "$rf" ]; then
echo "$rf exists "
else
echo "$rf doesnt exist. do you want to create it? ( y/n) ?"
read
fi
if [ "$REPLY" = "y" ]; then
echo "$rf creating.."
else
echo -n "creation failed"
echo -n "thats it.we're sadly done for now"
exit
if eval "touch randomfile.sh"
then
echo -n "creation successfully"
else
echo -n "creation failed"
echo -n "starting now to copy $rf to home/flo/downloads"
cp randomfile.sh /home/flo/Downloads/
echo -n "file should be copied. pls check it and make sure..!"
exit
fi
}
}
function logOutput() {
echo -en `date +%T`": $1\n"
}
function testcopy() {
if eval "cp filechecker.sh /home/flo/Downloads/"
then
echo -n "copy succeeded"
else
echo -n "couldnt copy file im sry"
fi
}
case $1 in
c*)
doCheck
;;
h*)
logOutput "-help .."
;;
*)
echo "Usage: EASY "
echo " Press scriptname.sh help for help "
echo " Press scriptname.sh check to use the tool "
;; esac
case $2 in
t*)
doTestCopy
;;
h*)
testcopy " to create a testcopy just press scriptname.sh testcopy "
;;
*)
echo " Usage: just press script.sh testcopy "
;; esac
as you can see its a simple check data, copy data script . not much of a script.
my error:
line 133 syntax error near unexpected token }.
help would be kindly appreciated.
thx