Operating System - HP-UX
1855786 Members
2568 Online
104103 Solutions
New Discussion

Re: How to ftp some files from a shell script

 
Siti
New Member

How to ftp some files from a shell script

I have 2 hosts src,trg.trg is a ftp server.
I need a script which will run once a day in src.
It will pick the files then put them into the trg host using ftp.
I saw one thread but my requirement is more than one file need to be ftp'd.
3 REPLIES 3
Ivan Krastev
Honored Contributor

Re: How to ftp some files from a shell script

See this previous thread - http://forums12.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1212577427760+28353475&threadId=1046219


Instead of using PUT you can use MPUT for multiply files.


regards,
ivan
marvik
Regular Advisor

Re: How to ftp some files from a shell script

Hi,

If u have SSH installed i think u can easily do that by copying the rsa keys of the userA on the source server to the ~homedir_of_userA/.ssh/auhorized_keys file in the target server.This way it will not promt password and scp will do your job.

Its too fast as well

Hope that helps

Cheers
Marvik
Laurent Menase
Honored Contributor

Re: How to ftp some files from a shell script

DESTSYS=mytargetsys
DESTDIR=/tmp/here
USER=myuser
PASSWD=mypasswd
ftp -n << EOF
connect $destinationsystem
user $USER $PASSWD
prompt
bi
cd $DESTDIR
mput *
by
EOF

or

(cat <connect $destinationsystem
user $USER $PASSWD
prompt
bi
cd $DESTDIR
EOF
for i in *.img # or here any script to get th
do
echo put $i
done
echo by
)| ftp -n

to get a log file
before you can do
exec >/tmp/ftp$$.log 2> /tmp/ftp$$.err