Running SFT from a Shell Script

If required, you can run the sft utility from within a shell script. An example shell script is shown below:

# SFT script
# redirect standard output and error output to sftlogfile
sft >sftlogfile 2>&1 << !!
# connect to a remote environment
connect SPI-20 PROG1 TEST
# get an item from the remote environment
get
AMERICA miami
galaxy/world/america
# disconnect
disconnect
!!
# test for success
if [ $? -ne 0 ]
then
   echo failed
else
   echo ok
fi

The above script connects to a remote environment, retrieves an item from a file and then disconnects. When sft is terminated, the number of unsuccessful get and put attempts is reported; this can be used to test whether all transfers have been successful. In the above script, this value is tested and, if the transfer has been successful, the message ok  is printed. If the transfer has failed, the message failed  is printed. Any input and output that would normally appear on the screen is written to a file called sftlogfile.