Syntax Error Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Syntax Error Script
# 8  
Old 09-10-2012
Quote:
Originally Posted by elixir_sinari
That will not work. You need to have a space after the file/directory name too. Also, the script provided has many other errors.
Yes elixir... there are lot of errors.....
Thanks....Smilie
This User Gave Thanks to pamu For This Post:
# 9  
Old 09-10-2012
Hammer & Screwdriver

Guys the error still persist in the same line 16..
# 10  
Old 09-10-2012
Code:
#!/bin/sh      # I am at the moment working on a AIX with no bash...
        #copiabin.sh: copia todos los archivos ejecutables a bin
        if [ ! -d $HOME/bin ]     # space was missing...
        then
           mkdir $HOME/bin
        fi
        # copia de archivos y contador N
        N=0 ; echo "N = "$N

        for ARCH in *
        do
           if [ -x $ARCH -a -f $ARCH ] # Si el archivo es ejecutable y es un fichero comun (no directorio)
           then
               cp $ARCH $HOME/bini
               echo " $ARCH fue copiado a $HOME/bin" ;  echo "N = "$N
               N=$(expr $N + 1)
           fi
        done
        echo "N = "$N
        read kyb   # This is so  to type enter to continue so I can look what is happening and follow...
        if [ $N -eq 0 ]
        then
            echo "No se copio ningun archivo"
        else
            echo "Se copiaron $N archivos"
        fi
~

output produced:
Code:
vbe@ son28: /home/vbe> ll
total 144
drwxr-xr-x    2 vbe      staff          4096 Sep 10 18:47 .
drwxr-xr-x   27 bin      bin            4096 Sep 05 11:31 ..
-rwxr-----    1 vbe      staff           105 Apr 30 2009  .kshrc
-rwxr-----    1 vbe      staff           272 Apr 30 2009  .profile
-rw-------    1 vbe      sysdso         1008 Sep 10 18:47 .sh_history
-rw-------    1 vbe      sysdso           54 Sep 10 18:46 .vi_history
-rw-r--r--    1 vbe      sysdso        34146 Sep 10 17:32 smit.log
-rw-r--r--    1 vbe      sysdso          946 Sep 10 17:31 smit.script
-rw-r--r--    1 vbe      sysdso         2292 Sep 10 17:31 smit.transaction
-rwxrwxr-x    1 vbe      sysdso          582 Sep 10 18:46 test001
vbe@ son28: /home/vbe> ./test001
N = 0
 test001 fue copiado a /home/vbe/bin
N = 0
N = 1

Se copiaron 1 archivos
vbe@ son28: /home/vbe> ll
total 152
drwxr-xr-x    3 vbe      staff          4096 Sep 10 18:49 .
drwxr-xr-x   27 bin      bin            4096 Sep 05 11:31 ..
-rwxr-----    1 vbe      staff           105 Apr 30 2009  .kshrc
-rwxr-----    1 vbe      staff           272 Apr 30 2009  .profile
-rw-------    1 vbe      sysdso         1128 Sep 10 18:49 .sh_history
-rw-------    1 vbe      sysdso           60 Sep 10 18:49 .vi_history
drwxr-xr-x    2 vbe      sysdso          256 Sep 10 18:49 bin
-rwxr-xr-x    1 vbe      sysdso          583 Sep 10 18:49 bini
-rw-r--r--    1 vbe      sysdso        34146 Sep 10 17:32 smit.log
-rw-r--r--    1 vbe      sysdso          946 Sep 10 17:31 smit.script
-rw-r--r--    1 vbe      sysdso         2292 Sep 10 17:31 smit.transaction
-rwxrwxr-x    1 vbe      sysdso          583 Sep 10 18:49 test001

Anything else? (I am not going to check the logic...)

Last edited by vbe; 09-10-2012 at 01:55 PM.. Reason: was missing last line in output produced...added color
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Syntax error on script

Evening All (or morning for some), Could anyone have a look at the below and advise where i've going wrong with the syntax as i keep getting the below error while trying to run. Any help would be really apprecaited. ./testout: line 13: syntax error near unexpected token `else' ... (4 Replies)
Discussion started by: mutley2202
4 Replies

2. Shell Programming and Scripting

First Script Syntax Error

So, I'm writing my first shell script to try to speed up the process of creating lyric files for mocp and I don't know what the error is, but considering how short the code is, I'm betting it's something super-obvious. line 7: syntax error near unexpected token `echo' line 7: ` echo... (4 Replies)
Discussion started by: D351
4 Replies

3. Shell Programming and Scripting

Syntax Error in Script

Hi All, I am new to Unix, I have written the following script in ksh and get a syntax error :wall:. I need some help to figure out the error and reason. The script below uses some variables from an environment file, also it executes a sql file. The sql file is correct and has no problems. I... (1 Reply)
Discussion started by: disshort23
1 Replies

4. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

5. Shell Programming and Scripting

Syntax error in script

Hey guys keep having problems with the below script syntax error near unpexpected token '0' exit 0 I have two directorys backups and Usr in the usr i have sub dir's wp,ss,pic which i would like to back up (copy those directorys to the backups directory) with user acknowledgement from command line.... (2 Replies)
Discussion started by: Spartukus
2 Replies

6. Shell Programming and Scripting

Syntax error with a script

Hi I not sure what is wrong with my script... when I try to run it I get the follow error: "remove: syntax error at line 77: `end of file' unexpected" Thanks in advance for any help. ans=y while do while : do echo "Please enter a name that you... (3 Replies)
Discussion started by: simpsonjr
3 Replies

7. 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

8. Shell Programming and Scripting

Syntax error in script

I get this error when I try to run my script (BTW, this is a simple script I am supposed to write for my class) $ menuscript menuscript: syntax error at line 89 : `"' unmatched $ Here is the code (Any help is greatly appreciated) (Line numbers included) 1 #!/bin/ksh 2 ... (2 Replies)
Discussion started by: KindHead
2 Replies

9. Shell Programming and Scripting

syntax error in script !!

./disk_space_util.sh ./disk_space_util.sh: Syntax error at line 24 : `then' is not expected. ================================= cat disk_space_util.sh #!/bin/sh # # Parameter Settings ORA_LOG, ORA_SCRIPT, DBA_EMAIL_LIST -- (Set in .profile) bdf | sed "s/%/ /g" | sed "/Filesystem/d" |... (13 Replies)
Discussion started by: uuser
13 Replies

10. Shell Programming and Scripting

Syntax error in a script...

Hi All, I have been fighting with a syntax error for the last 2 days, still haven't got the solution. Could you please help me, your help will be greatly appreciated. In my script I am getting a error in a for loop, its similar to the one as is below. for v_id in v1 v2 v3 v4 do... (8 Replies)
Discussion started by: rajus19
8 Replies
Login or Register to Ask a Question