I'm working on some really old boxes with no bash, perl, or other scripting language. The task is to ftp several files to a long set of machines.
I've set this up as two shells. ftp-send.sh builds the list and calls ftpit.sh, which does the actual ftp command. Here's ftp-send:
#start the logfile
echo "ftp-send-update started at `date`">>$LOGFILE
for i in `cat $DESTLIST`
echo "Now sending to $i" >> $LOGFILE
if /upgrade_work/ftpit.sh $i; then
echo "Transfer to $i successful"
echo "Transfer to $i failed"
and here's ftpit.sh
ftp -n $1 <<EOF
user root foopass
The problem I'm having is that ftpit.sh is always returning zero. I've tried putting ftpit into the main shell as a function, but that doesn't work either. Can someone recommend a way to catch and pass a non-zero exit code when ftpit isn't able to connect?