Operating System - HP-UX
1825720 Members
3078 Online
109686 Solutions
New Discussion

ftp script from NT/W2K/W98 to L1000; HP UX 11.0

 
SOLVED
Go to solution
Richard Darling
Trusted Contributor

ftp script from NT/W2K/W98 to L1000; HP UX 11.0

One of our customers needs to send us ascii files from several MS boxes to our L1000. Our app on the L1000 will read each file to create a new end customer.

I set them up as a user on the L1000 and want them to ftp the files to that home directory.

They asked me to give them an ftp script, which I did:

ftp -i -n << EOF
open ip_of_my_L1000
user username passwd
put local_path_of_file_on_MS_machines
prompt off
bye
EOF

This works fine for me between UNIX systems, but they don't know how to get it to work on their PCs. I'm not sure how to get it to work in a script on a PC w/out accessing the script from "Start"; "Run", "Open" and run it as a script from that point.
Thanks.

5 REPLIES 5
Alan Casey
Trusted Contributor
Solution

Re: ftp script from NT/W2K/W98 to L1000; HP UX 11.0

You can create a batch file:

Just create a text file with it and rename it to:

name.bat
This will create an executable batch file similar to what you are using on UNIX.

There are also some versions of cron for windown around for free.
Alan Casey
Trusted Contributor

Re: ftp script from NT/W2K/W98 to L1000; HP UX 11.0

continued....

the batch file can go on the desktop and just double click it to run the job.
Can also be executed in dos.
Richard Darling
Trusted Contributor

Re: ftp script from NT/W2K/W98 to L1000; HP UX 11.0

Thanks Alan,
They were attempting to run it with a .com extension for some reason. Works fine now.
A. Clay Stephenson
Acclaimed Contributor

Re: ftp script from NT/W2K/W98 to L1000; HP UX 11.0

Hi Richard:


When I have to do ftp scripting nowadays, I use perl with the Net::FTP module (available for download at www.perl.org/CPAN). It really makes FTP operations very simple. Any error conditions and timeouts are easy to test for and set. The other advantage is that unlike shell script based solutions, your perl scripts can run unchanged on NT and W2K boxes if you install the freely available product ActivePerl (www.activeperl.com) . It's also very easy to add error checking as well. Be sure to download the Net::FTP module from www.perl.com/CPAN. It may be on ActivePerl's site as well.

It's usually something as simple as:

use Net::FTP;
use strict;

$ftp = Net::FTP->new("remhost.xxx.yyy", Debug => 0);
$ftp->login("anonymous",'cstephen@mama.com');
$ftp->cwd("/Downloads");
$ftp->get("Testfile.TXT");
$my $stat = $ftp->status;
if ($stat == 2)
{
print "Get was Good\n"
}
else
{
print "Get was bad; Status ",$stat,"\n";
}
$ftp->quit;

That truly is about as clean as it gets and with error checking to boot. With just a bit more work, you can add a signal handler to cover the timeouts in case a command hangs.


Regards, Clay
If it ain't broke, I can fix that.
Ian Dennison_1
Honored Contributor

Re: ftp script from NT/W2K/W98 to L1000; HP UX 11.0

OK, I did this a while ago but naturally lost the source.

ftp command in DOS = 'ftp -n -s:file1.txt hosta'. Stick it behind an icon or in a bat file.

Contents of file1.txt contain the ftp commands as follows,...
user root/passwd
cd bla bla bla
get bla bla bla
bye

If you want to avoid prompts, use the -i option on the ftp command. PS. I have just finished testing this, it should work OK.

Share and Enjoy! Ian
Building a dumber user