A Conversation for The H2G2 Programmers' Corner

Automated FTP (AIX)

Post 1

IctoanAWEWawi

Howdo, I'll apply to sign up shortly, honest!

Anyone out there done automated FTP Shell scripts under Unix? Am using AIX and csh at the mo.

I can do all the automated stuff with logins and whatnot (using the .netrc file) BUT how do I get ftp to bomb out if the password in the .netrc is not correct?

At the moment, all it does is go to the FTP> prompt and sits there, which ain't a lot of use in an automated batch system as the scheduler will just sit around and wait for it. Presumably for ever smiley - smiley

I really don;t want to have to use XCOM smiley - sadface


Automated FTP (AIX)

Post 2

Menza

If you were doing it in perl you could use the LWP package to play with FTP. I don't do very much with shell scripts, sorry.


Automated FTP (AIX)

Post 3

IctoanAWEWawi

Cheers anyway, 'fraid I just missed out on all this high falutin' perl and stuff! Shell scripts and procedural languages only smiley - smiley

Ta for the reply tho'


Automated FTP (AIX)

Post 4

DoctorMO (Keeper of the Computer, Guru, Community Artist)

Yes, Perl sounds good to me too... but I'll have a look around for ya.

-- DoctorMO --


Automated FTP (AIX)

Post 5

IctoanAWEWawi

Where does perl reside under *nix? I'll have a look to see if we have it.
Guess now is as good a time as any to learn something new....


Automated FTP (AIX)

Post 6

Menza

Typically its in one of

/usr/bin/perl
/usr/local/bin/perl

depending on how your system is set up. Try typing "perl -v" to get the version info up, that will at least tell you if its installed.


Automated FTP (AIX)

Post 7

DoctorMO (Keeper of the Computer, Guru, Community Artist)

or if your package dosn't come with it (god forbid) I'm sure you can download it.

-- DoctorMO --


Automated FTP (AIX)

Post 8

IctoanAWEWawi

Yep, got it! in /usr/bin ver 5.005_03.

No man pages tho'. Just looking through a few web pages for Perl newbies. So far seems to be a cross between shell script and C.

thanks for the help so far, I shall be back!

And I've written my first interactive 'Hello ictoan' program in Perl!
Woo!

Does that mean I can now put 'Perl Expert' on my CV and go contracting for huge sums of money? smiley - winkeye


Automated FTP (AIX)

Post 9

Menza

If you want a place to look for handy perl modules go to

http://www.cpan.org

Lots of freely downloadable perl modules for you to play with.


Automated FTP (AIX)

Post 10

Ion the Naysayer

"which " (e.g. which perl) will find an installed executable under Unix. You can get perl from http://www.cpan.org or any of its mirrors.

If you need some Perl quick and dirty, try http://www.perldoc.com. If you have specific questions, a good place to ask is http://www.perlmonks.org. The most comprehensive documentation I've found is the Camel book - O'Reilly and Associates "Programming Perl". It was written by a few authors including Larry Wall (who wrote the language) so it's pretty much all-encompasing. Okay, not all. There's also Learning Perl, Advanced Programming Perl, etc., etc.. You can find the books and such at O'Reilly's website. They also have online versions in their "Safari" service which I've found useful. They have a free trial offer which is quite nice - try before you buy. Mine's about to expire though smiley - sadface.


Automated FTP (AIX)

Post 11

IctoanAWEWawi

Sussed it under shell:-

Assuming you have a .netrc file under the user with the stuff defined, then ftp'ing with the password in the .netrc set incorrectly will returns:-

[DFSL]/home/me $ echo "" | ftp machine1
Login incorrect.
Login failed.
[DFSL]/home/me $

The messages being on STDERR so calling it from the batch with a 2>&1 will catch it!

Although for the sake of my CV I think I shall try and do the same thing in perl smiley - biggrin


Key: Complain about this post