[NTLUG:Discuss] Bash related question

Alton R. Pouncey, II alton at trainers-r-us.com
Mon Feb 10 09:47:10 CST 2003


On Mon, 2003-02-10 at 01:33, 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"
> 

bash requires whitespace after the opening [ and before the closing ]. 
So, syntactically, this would work:

line 2:	if [ $retvalue -ne 0 ]

This will take care of the line 2 error.

<...snip...>

> Thanks,
> - Harshal.
> _______________________________________________
> https://ntlug.org/mailman/listinfo/discuss

You're welcome,
Alton

-- 
Alton R. Pouncey, II
SCSA, SCNA, CCNA, CIW Professional
http://www.trainers-r-us.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: This is a digitally signed message part
Url : http://ntlug.org/pipermail/discuss/attachments/20030210/8c457cc7/attachment.bin


More information about the Discuss mailing list