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:
Code:
RUNDATE=`date +%Y%m%d%H%M`
echo $RUNDATE
LOGFILE=ftp-send$RUNDATE.log
#start the logfile
echo "ftp-send-update started at `date`">>$LOGFILE
DESTLIST=ftp-destination-list.txt
for i in `cat $DESTLIST`
do
echo "Now sending to $i" >> $LOGFILE
if /upgrade_work/ftpit.sh $i; then
echo "Transfer to $i successful"
else
echo "Transfer to $i failed"
fi
done
and here's ftpit.sh
Code:
ftp -n $1 <<EOF
user root foopass
binary
put foo1.txt
bye
EOF
print $?
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?
TIA Dave