Operating System - HP-UX
1838078 Members
3747 Online
110124 Solutions
New Discussion

Re: Ftp automaticly on HPUX11

 
SOLVED
Go to solution
Romeo_Lou
Advisor

Ftp automaticly on HPUX11

How can I use Ftp to another host automaticly?
I had set the .netrc, but it just allow to log into the remote host without supplying your remote login name and password.
I want to more function about put files automaticly.
pls help ,tks
4 REPLIES 4
Kenny Chau
Trusted Contributor

Re: Ftp automaticly on HPUX11

You can use ftp -i -n < file.

"file" will contain:

open
user
commands
commands
bye

You can put this to your cron job.

Hope this helps.
Kenny.
Kenny
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Ftp automaticly on HPUX11

A much better and cleaner way to get/put files is to use Perl; I never do this stuff in the shell anymore because with Perl the error checking is built right in.

It first logs you in to a remote server, change the remote host, user, and password to suit your needs. It then does a cwd to /tmp and puts ftp in 'binary mode'. It then reads the command line for filenames to send. It will try each one up to 5 times. The beauty of doing this in perl is that the error checking is built right in. You will need to download and install the Net::FTP module from http://www.perl.org/CPAN but after that you are done. I never bother trying to do this stuff in the shell anymore because this is so much easier.

Ig you want to change this to a 'get' simply replace the put with a get in the perl script and you are done.

P.S. If you need to punch through a proxy server, simply supply a 3rd argument to the login subroutine and it will be just like you typed the account ftp command yourself.

Regards, Clay


If it ain't broke, I can fix that.
Michael Tully
Honored Contributor

Re: Ftp automaticly on HPUX11

Create a text file as follows:
open hostname
user username password

bye

Run the ftp command as follows:
ftp -i -n
For example, if you want to transfer files from a host called fred to your
system. The files need to be transferred in binary mode and the username for
logging into fred is myuser with a password of qwerty1. The files are located
in /home and have an extension of .txt The files will be transferred to /tmp on
your system.


Create a text file called ftp.txt with the following lines:

open fred
user myuser qwerty1
binary
mget /data/*.txt /tmp/*.txt
bye

Run the ftp command as follows:

ftp -i -n
If you want to do automatically you can use 'cron' or 'at' to do when convenient to you.

HTH
-Michael
Anyone for a Mutiny ?