Hi there all..
I have the following.
I have a FTP someware where raports are put on.
I have to FTP to it and get them in and than delete the remote
But all the time there are new files put in, so I dont want to delete after I copy, becouse than I can delete files that are not yet copyed.
And it is kinda sensetive information as in no body will be able to read it but it better not get deleted withoud getting a copy on this side.
I build this script, and well it is getting the files but it is not putting the files to the correct local dir. and I disabled the mdelete function for now, so I dont loose files, but I want to use that the same as the mget.
Code:
#!/usr/bin/ksh
#
set -x
## VARIABLES##
RNODE="192.168.10.30"
USER="*****"
PASSWD="********"
LOCALDIR="/glims/mgnt/mmpamm"
REMOTEDIR=""
DIRLISTFILE="${LOCALDIR}/${RNODE}.$(basename ${REMOTEDIR}).dirlist.out"
cat /dev/null > $DIRLISTFILE
HISTLOG=/glims/mgnt/mmpamm/logs/ftphist.log
FTPLOG=/glims/mgnt/mmpamm/logs/ftptrans.log
glimspad=/glims/mgnt/mmpamm
ERROR_FILE=/glims/mgnt/mmpamm/errorfile
HOSTNAME=`uname -n`
## DEFINE FUNCTIONS HERE ##
######### Check if there is an error file #########
function errorfile_check
{
if test -r $ERROR_FILE
then
rm $ERROR_FILE
fi
}
######### Ping check if host is avalible #########
function ping_check
{
ping $RNODE -n 2 > $glimspad/pingctrl.txt
PINGCTRL=`cat $glimspad/pingctrl.txt | wc -l`
}
######### ERROR report #########
function report_ERROR
{
echo `date '+%d %b %H:%M:%S'` $RNODE NIET gevonden >> $HISTLOG 2>&1
echo stop `date '+%d %b %H:%M:%S'` >> $HISTLOG 2>&1
touch $ERROR_FILE
echo `date '+%d %b %H:%M:%S'` "communicatie PC: $RNODE" >> $ERROR_FILE
echo "Let op !!!!!" >> $ERROR_FILE
echo "" >> $ERROR_FILE
echo "Fout tijdens overdracht PAMM" >> $ERROR_FILE
exit
}
######### File check from host (FTP) #########
function file_check_host
{
ftp -i -v -n 192.168.10.30 <<END_FTP
user $USER $PASSWD
nlist $REMOTEDIR $DIRLISTFILE
bye
END_FTP
}
######### File Copy from host (FTP) #########
function file_copy_host
{
ftp -i -v -n 192.168.10.30 <<END_FTP
user $USER $PASSWD
lcd $LOCALDIR
cd $REMOTEDIR
mget $DIRLISTFILE
bye
END_FTP
}
######### File Remove from host (FTP) #########
function file_remove_host
{
ftp -i -v -n $RNODE <<END_FTP
user $USER $PASSWD
# mdelete
bye
END_FTP
}
## BEGINNING OF MAIN ##
errorfile_check
ping_check
if pingctrl=7
then
file_check_host
sleep 5
file_copy_host
sleep 5
file_remove_host
fi
# End of script