Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

lftp not working inside loop

591309Jun 20 2009 — edited Jun 21 2009
Hi all,
I am trying to automate the ftp process.I have to copy a file from 28 different locations.I have used lftp.
The script is below posted:
>
#
#!/bin/bash
USR=treas
PWD=treas
DATE=$(date)
#for i in `cat IP`;do
sort IP| while read NAME IPADD; do
ping -c 1 $IPADD |grep "1 received" > /u/impbkup/$NAME.txt
if [ `cat /u/impbkup/$NAME.txt|wc -l` = 1 ] ; then
#if [ $? -ne 0 ];then
cd /u/impbkup
#ftp -n $IPADD << EOF
#user $USR $PWD
lftp -u $USR,$PWD $IPADD <<EOF
cd /u1/impbkup
mv expdat.dmp.gz $NAME.dmp.gz
mget $NAME.dmp.gz
EOF
else
echo "$NAME is down on $DATE " >$NAME_dwn.txt
fi
done
exit


When i run the script,it says cd :login failed
mv:login failed

mget:login failed

However if I run the comands as
lftp -u usr,pwd 80.0.0.1<<eof
cd /u1/impbkup
mv expdat.dmp.gz host1.dmp.gz
mget host1.dmp.gz
eof

It works fine.I am unable to achieve the same functionality inside loop.

Also,instead of mv i want to copy the file expdat.dmp.gz with the name host1.dmp.gz so that both file exist.And when host1.dmp.gz is copied,it should be deleted from the remote server so that only expdat.dmp.gz exists
.
Any help would be appreciated.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2009
Added on Jun 20 2009
3 comments
2,372 views