[NTLUG:Discuss] Bash related question

Vaidya, Harshal (Cognizant) HarshalV at pun.COGNIZANT.COM
Mon Feb 10 01:33:28 CST 2003


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"

Moreover, the statement 6 is printed sometimes before the transfer starts and other times after the transfer  completes. Basically, it dosent run sequentially like a normal C program.

One thing which comes to my mind is that when bash runs the sftp2 command it runs it as a parallel command in a subshell. May be thats why the statement 6 is printed with no sequence in particular.

I want to ask you guys whether what I am thinking is correct or is there a different theory to this?

If this is really true then how do I detect whether the sftp2 command ran successfully or not?

Thanks,
- Harshal.


  
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: InterScan_Disclaimer.txt
Url: http://ntlug.org/pipermail/discuss/attachments/20030210/05c1295d/InterScan_Disclaimer.txt


More information about the Discuss mailing list