Operating System - HP-UX
1833776 Members
1950 Online
110063 Solutions
New Discussion

script to ftp the file from local drive to hp unix drive

 
SOLVED
Go to solution
Leah Chow
Frequent Advisor

script to ftp the file from local drive to hp unix drive

Hello,

Is there any way to write a dos bat command to ftp a text file from my local drive to hp server? The files stay in my c drive, I need to run those files in unix server. So the script should run automatically, the user doesn't need to key in the username and password.

thanks a lot
Leah
9 REPLIES 9
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: script to ftp the file from local drive to hp unix drive

I wouldn't dream of doing it in a .bat file but it's very easy to in Perl. Get a free version pf Perl for your windows box from www.activestate.com and then excute the attached Perl script, ftpget.pl. Invoke as ftpget.pl -u for full usage; it will make your task very easy.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: script to ftp the file from local drive to hp unix drive

Ooops, you are xferring in the other direction; you need ftpput.pl. Invoke as ftpput.pl -u for full uage.

If it ain't broke, I can fix that.
Leah Chow
Frequent Advisor

Re: script to ftp the file from local drive to hp unix drive

hi Clay,

the scirpt you provide me should run under window or hp sever? As soon as i typed : ftpput.pl -u, the script itself will pop-up.

Sorry, i know nothing about Perl, I downloaded the Activeperl for windows, and installed on my c drive.

Leah Chow
Frequent Advisor

Re: script to ftp the file from local drive to hp unix drive

hi Clay,

the scirpt you provide me should run under window or hp sever? As soon as i typed : ftpput.pl -u, the script itself will pop-up.

Sorry, i know nothing about Perl, I downloaded the Activeperl for windows, and installed on my c drive.

Thanks
A. Clay Stephenson
Acclaimed Contributor

Re: script to ftp the file from local drive to hp unix drive

Actually the script will run on either Windows or HP-UX. In your case, because almost certainly there is no ftp daemon running on your Windows box, you would execute the perl script on your PC as an ftp client.

Let's suppose that you want to transfer the file "myfile.txt" located in your CWD on your windows box to directory /xxx/yyy on your HP-UX box.


Your Windows command could look like this:


perl ftpput.pl -l cstephen -p topsecret -A -d /xxx/yyy myfile.txt

If you have configured your Windows box to recognize the ".pl" extension then the "perl" part of the command is not needed.

We just told the command to login as user "cstephen"; password "topsecret"; -A (ASCII mode; you said textfile); cd to /xxx/yyy and finally put the file myfile.txt.



If it ain't broke, I can fix that.
Leah Chow
Frequent Advisor

Re: script to ftp the file from local drive to hp unix drive

thanks a lot for your help, got it!! you are great.
Keith Buck
Respected Contributor

Re: script to ftp the file from local drive to hp unix drive

You can also use pscp (comes with putty, a free ssh client for Windows...). Once you have your keys setup (putty comes with a key generation utility, and then you can put the public key on the remote system in the ~/.ssh/authorized_keys file), this is just one line that you can put in your .bat file.

pscp localfile user@remotehost:/path/to/remotefile

It also uses the more secure ssh protocol rather than cleartext, unauthenticated ftp.

You would also need HP-UX Secure Shell installed on your HP-UX machine (comes with the latest OEs or you can download it from software.hp.com)

Hope that helps

-Keith
Peter Godron
Honored Contributor

Re: script to ftp the file from local drive to hp unix drive

Leah,
here is a DOS solution:
echo user USERID PASSWORD > a.lis
echo ls >> a.lis
echo bye >> a.lis
ftp -n -d -s:a.lis IPADDRESS
del a.lis

where variable to be coded are in UPPERCASE
e.g IPADDRESS 123.234.123.234
Leah Chow
Frequent Advisor

Re: script to ftp the file from local drive to hp unix drive

Thank you Keith and Peter, i tried your ways too, they all work great. thanks a lot for your help.

Leah