The script follows, I hope you can read it ok. I tried puting this in a function as you will see and still not working. When you get to the bottom I have the ftp part of the script commented out because I was tring a function. It still gives me the same error.
Thanks for your help.
#!/bin/ksh
###############################################################################
# Written by: Jesse Hardy September 18, 2001 #
# This script will take files from Berlin and ftp them to Detroit #
###############################################################################
###############################################################################
# Setting up some variables #
###############################################################################
FTP="/usr/bin/ftp"
HOME="/b/00/sour/incenprd/tocmg"
DHOME="/hdgstg01/applr11i/common/incenprd/incoming"
CHO="/usr/bin/chown"
CHG="/usr/bin/chgrp"
CAT="/usr/bin/cat"
MV="/usr/bin/mv"
COMM="/usr/bin/comm"
CP="/usr/bin/cp"
function ftp_files
{
$FTP detroit <<END
ascii
lcd $HOME
cd $DHOME
put $file
quit
END
}
###############################################################################
# This control statement will go to the home directory and list the contents #
# of that directory and will compare the contents of that listing with the #
# contents of the comparison file. It will also move whatever is different #
# to a holding file handle for later manipulation #
###############################################################################
cd $HOME
ls -l|nawk '{print $9}' > newfile
if [[ -f $HOME/oldfile && -f $HOME/newfile ]]
then
difffile=$($COMM -3 oldfile newfile)
fi
###############################################################################
# I had to move this out of the control statement because I couldn't assign #
# the output of the comm command to a variable and a file at the same time. #
###############################################################################
cd $HOME
$COMM -3 oldfile newfile > filediff
$CP $HOME/newfile $HOME/oldfile
> newfile
###############################################################################
# This control statement checks for the existance of the filediff file and if #
# it is there is it empty, if it is empty prints no new files if it is not #
# empty then it emails Dominick that there is a new file in the directory #
###############################################################################
if [[ -f $HOME/filediff && -s $HOME/filediff ]]
then
$CAT $HOME/filediff|mailx -s "There are new file(s) in the $HOME directory" ddisalvo@domain.com,jhardy@domain.com
else
print "No new files"
fi
################################################################################
# This control statement will check $difffile to see if it is empty if it is it#
# kill the script if not it will ftp file(s) #
################################################################################
if [[ -z $difffile ]]
then
kill $$
fi
cd $HOME
#files=$($LS|$WC)
#lines=$($CAT oldfile)
for file in filediff
do
ftp_files
# $FTP detroit <<END
# ascii
# lcd $HOME
# cd $DHOME
# put $file
# quit
# END
done