[NTLUG:Discuss] Bash related question

Greg Edwards greg at nas-inet.com
Mon Feb 10 02:54:31 CST 2003


Vaidya, Harshal (Cognizant) wrote:
> Hi,
> 
>   Consider this snippet of a bash script i am writing.
>   
> 1  retvalue = $(sftp2 -B ftpcommands db2admin at cq7092)
> 2  if [$retvalue -ne 0 ]
> 3   then
> 4  echo "file transfer failed"
> 5   else
> 6  echo "file transfer was successful"
> 7  fi
> 
>  When i run this script, the transfer actually completes successfully but i get an error at line 2 saying that 
>     " [: too many arguments"
> 

> 
> Thanks,
> - Harshal.
> 

Line #2 has a syntax error.

bad

if [$retvalue -ne 0 ]

good

if [ $retvalue -ne 0 ]

the space after the open [ matters.

-- 
Greg Edwards




More information about the Discuss mailing list