Syntax error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Syntax error
# 1  
Old 01-21-2014
Syntax error

hey guys, im very new to shell programming and ive been experimating the whole day.

sadly im stuck now with my code:

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

Last edited by bartus11; 01-21-2014 at 10:32 AM.. Reason: Please use CODE tags instead of ICODE
# 2  
Old 01-21-2014
I suggest, first indent your code, you would probably know the error by own. We would also need to do that as the very first task.

---------- Post updated at 20:23 ---------- Previous update was at 20:14 ----------

Did the same, May be..


Code:
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
fi

This User Gave Thanks to clx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Getting this error syntax error near unexpected token `)'

Hi Everyone, my script was running Ok, but suddenly it started giving this error. ./update_env_bi.sh: line 54: syntax error near unexpected token `)' ./update_env_bi.sh: line 54: `sed -i "s/PORT=*1/PORT=$2/" repository.xml' The line 54 has this code. sed -i "s/PORT=*1/PORT=$2/"... (2 Replies)
Discussion started by: shajay12
2 Replies

2. Shell Programming and Scripting

IF section problem. syntax error: unexpected end of file error

Hello, I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time. My script: returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned if ; then echo "There is no errors in the logs" fi And after... (10 Replies)
Discussion started by: jedzio
10 Replies

3. Linux

Ambiguous redirect error and syntax error when using on multiple files

Hi, I need help on following linux bash script. When I linux commands for loop or while loop on individual file it runs great. but now I want the script to run on N number of files so it gives me ambiguous redirect error on line 12 and syntax error on line 22 : (pls help ); #!/bin/bash #... (16 Replies)
Discussion started by: Madhusudan Das
16 Replies

4. Shell Programming and Scripting

Receiving error: ./ang.ksh[35]: 0403-057 Syntax error at line 116 : `done' is not expected.

Hi All I am quite new to Unix. Following is a shell script that i have written and getting the subject mentioned error. #!/bin/ksh #------------------------------------------------------------------------- # File: ang_stdnld.ksh # # Desc: UNIX shell script to extract Store information.... (3 Replies)
Discussion started by: amitsinha
3 Replies

5. Shell Programming and Scripting

ERROR: ./launch_full_backup.sh[18]: Syntax error at line 28 : `else' is not expected.

Help please! :confused: I have the following error with the following file and the emails are not arriving to the email, any idea please? ERROR: ./launch_full_backup.sh: Syntax error at line 28 : `else' is not expected. FECHA=`date +%d%m%y%H%M`... (2 Replies)
Discussion started by: villenan
2 Replies

6. Programming

Newbie Question.. -> error: syntax error before ';' token

Hello, the following is generating a error at the line "tmprintf(&tmBundle, _TMC("{0}"),Prompt);"... a bit lost as I am diving into this debug... Thank you in advance... int H_YesNo(TMCHAR *Prompt, int DefVal) { TMCHAR YesNo = '\0'; tmprintf(&tmBundle, _TMC("{0}"),Prompt); while... (3 Replies)
Discussion started by: reelflytime
3 Replies

7. Shell Programming and Scripting

sed error : Syntax error: redirection unexpected

My script is throwing the error 'Syntax error: redirection unexpected' My line of code.. cat nsstatustest.html | sed s/<tr><td align="left">/<tr><td align="left" bgcolor="#000000"><font color="white">/ > ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3 HTML tags are getting in the way but they're needed to... (3 Replies)
Discussion started by: phpfreak
3 Replies

8. AIX

nim mksysb error :/usr/bin/savevg[33]: 1016,07: syntax error

-------------------------------------------------------------------------------- Hello, help me please. I am trying to create a mksysb bakup using nim. I am geting this error, how to correct it ? : Command : failed stdout: yes stderr: no... (9 Replies)
Discussion started by: astjen
9 Replies

9. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies
Login or Register to Ask a Question