Operating System - HP-UX
1833019 Members
2334 Online
110049 Solutions
New Discussion

Re: FTP of one file - Struggling

 
SOLVED
Go to solution
Rudi Martin
Advisor

FTP of one file - Struggling

Hi there everybody

I need to ftp a file to a host that uses an username and password. Is there any way I can copy this file , for example with rcp , to the host or can anyone help with a script that can do this ?

Thanks !
11 REPLIES 11
Michael Tully
Honored Contributor

Re: FTP of one file - Struggling

Are we talking about Unix to Unix or something else.

Exactly what problem do you encounter?
Anyone for a Mutiny ?
Rainer von Bongartz
Honored Contributor

Re: FTP of one file - Struggling

If you need to ftp the file, so why don't you use ftp ??


I'm not clear about your problem

Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Rudi Martin
Advisor

Re: FTP of one file - Struggling

Hi All

Just to make it a bit clearer. I can use ftp , no problem at all , but I want to automate it , it's gonna run every 2 hours every day. How do I get past the username and password issue ?
Rainer von Bongartz
Honored Contributor

Re: FTP of one file - Struggling

I see,

so of course you could use rcp for this task.

you have to set up a hosts.equiv file on the target machine with entry:



Regards
rainer

He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Rainer von Bongartz
Honored Contributor

Re: FTP of one file - Struggling

BTW.

if it is a big file, you should consider using rsync which will only transmit the differences of both files

Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Paul Barker
Occasional Advisor
Solution

Re: FTP of one file - Struggling

You can of course automate ftp from within a script if you don't mind the password appearing in the script:

ftp -n -v -i host 2> /dev/null 1> /var/tmp/ftp.log << !
user ftpuser ftppassword
cd /tmp
put file.txt
bye
!

But I guess that the rsync option may be a better bet.
Jan Sladky
Trusted Contributor

Re: FTP of one file - Struggling

hi,
for automatic ftp you can use folowing script launched by cron

23 59 * * * /usr/bin/ftp /usr/bin/ftp -i -n -v < mybackup.sh

cat mybackup.sh

open 10.32.113.177 # destination
user ford abcd #abcd is password
hash
prompt off
cd /dir
mput file_you_want_to_backup
bye

at midnight you have your backup in /dir

br Jan
GSM, Intelligent Networks, UNIX
Muthukumar_5
Honored Contributor

Re: FTP of one file - Struggling

If you want to automating and simulating it for 2 hours then use rcp. It is effective. If you want to use secure then use scp.

To use rcp set .rhosts file in $HOME directory on two servers.

rcp :file-path

To do it for two hours, use crontab to it.

Easy to suggest when don't know about the problem!
Jose Mosquera
Honored Contributor

Re: FTP of one file - Struggling

Hi,

rcp its always a secure way than ftp because you never write the password.

In your target $HOME user's directory (suppose userB1 into serverB box) set a .rhosts file:

Where:
must be reachable
must be the user that start the rcp session from source.
i.e:
serverA userA1

From serverA and userA1 $HOME dir:
/usr/bin/rcp userB1@serverB:

This must be successful. Then, to automate this proccess each two hours set userA1 cronfile (crontab -e) with the following schedule:
00 0,2,4,6,8,10,12,14,16,18,20,22 * * * /usr/bin/rcp userB1@serverB:

Remember allow cron execution for userA1 include it into /var/adm/cron/cron.allow file.

Rgds.
rmueller58
Valued Contributor

Re: FTP of one file - Struggling

I use expect for automating script.

#!/usr/bin/expect
spawn ftp
expect "Name"
send "user\r"
expect "Password:"
send "password\r"
expect "ftp> "
send "lcd /home/xfer\r"
expect "ftp> "
send "cd /tmp/xfer\r"

expect "ftp> "
send "mput *\r"
expect "ftp> "
send "quit\r"
Brian Hackley
Honored Contributor

Re: FTP of one file - Struggling

Hi,

man netrc
.netrc file allows HP-UX FTP command to do automated login to another host.

Follow all security suggestions.

HTH,
-> Brian Hackley
Ask me about telecommuting!