Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP

Status
Not open for further replies.

dshaw21369

Programmer
Jul 8, 2002
64
Hi,
I'm new to unix and I'm was wondering if anyone might know how to do the following:

1.find files with *in extension in over 20 directories on Server A
2.FTP these files to 20 seperate directories on to Server B (where the script is running)

I'm interested in using the find command if I could.

thanks
 
Something like:

#!/bin/ksh
DATADIR=/data/
COMMAND=$(basename $0) # This command file
RHOST=100.204.18.22
RUSER=puser
RPASS=ppass

function send_mail_to_support
{
echo $* | /scripts/mail_support "FILE TRANSFER PROBLEM"
}

echo "machine ${RHOST}
login ${RUSER}
password ${RPASS}
" > ${HOME}/.netrc
chmod 600 ${HOME}/.netrc

cd $DATADIR

for DATAFILE in `find . -name "yourfiles*" -print`
then
#Your remote directory would have to be named like existing directory of file - cut at approp. places
DATADIR2=`echo $DATAFILE|cut -c??-??`
echo "cd ${DATADIR2} " > ${DATADIR}/.$COMMAND.tmp
echo "put ${DATAFILE} " >> ${DATADIR}/.$COMMAND.tmp
echo "bye" >> ${DATADIR}/.$COMMAND.tmp

cat ${DATADIR}/.$COMMAND.tmp | ftp -i -v ${RHOST} > ${DATADIR}/.$COMMAND.out 2>&1
chmod 666 ${DATADIR}/.$COMMAND.tmp ${DATADIR}/.$COMMAND.out 2>/dev/null

if fgrep -q "Transfer complete" ${DATADIR}/.$COMMAND.out
then :
else
send_mail_to_support "Problem sending file ${DATAFILE}"
fi
else
send_mail_to_support "No files to transfer"
fi


HTH Dickie Bird (:)-)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top