Home » Infrastructure » Unix » ftp script
ftp script [message #367054] Fri, 06 October 2000 23:11 Go to next message
zed simms
Messages: 1
Registered: October 2000
Junior Member
hello all,
i need a unix script to be executed which will ftp into a couple of machines and get files from them. It will log in using "admin" but the password has a certain pattern. It starts with this pattern "admin***".
the *** is the last number of the IP address, for instance, a 10.1.1.5 machine has a admin5 password.
please help.
thanks.
Re: ftp script [message #367056 is a reply to message #367054] Tue, 10 October 2000 00:31 Go to previous message
sandeep
Messages: 110
Registered: October 2000
Senior Member
scripts for ftp to particular machine :

### Following Fuction Will Send the files across
# In Parameters - FTP Directory
# - FTP File
# - IP Address
# - HOST Directory
# Function Called By Shell Script
###
SendData()
{
FTP_DIR=$1
FTP_FILE=$1
IP_ADDR=$3
HOST_DIR=$4
FTP="ftp -nvd"
PASS=admin`echo ${IP_ADDR}|cut -d"." -f4`

${FTP} ${IP_ADDR} <<-ENDFTP 2>&1
user admin ${PASS}
prompt off
put ${FTP_DIR}/${FTP_FILE} ${HOST_DIR}/${FTP_FILE}
bye
ENDFTP
unset FTP_DIR FTP_FILE IP_ADDR HOST_DIR
}

#Lets say you call the above function in shell like

SendData "/home/ftp" "ftpfile.txt" "10.4.0.1" "/home/hostdir" > /tmp/ftp.log

## or if you are passing these parameters to ## shell in variables.lets say SH1 ,SH2 ,SH3,SH4 ##then SendData ${SH1} ..... ${SH4}
SendData ${SH1} ${SH2} ${SH3} ${SH4} > /tmp/ftp.log
chmod 777 /tmp/ftp.log
egrep "Transfer complete" /tmp/ftp.log > /dev/null
if [[ $? = 0 ]]
then
echo "Success"
rm -f /tmp/ftp.log
else
echo "Failure..check /tmp/ftp.log for details"
fi

## You can have another fn for getting data from host or can ## have it in same fn (both put & get )

Hope this works
Previous Topic: Post-Wait Kernel/etc/pw-syscall Please help
Next Topic: ASP scripts with oracle on a Unix box
Goto Forum:
  


Current Time: Fri Apr 19 13:47:25 CDT 2024