SUMMARY-Automatic FTP.

From: Simon Convey (
Date: Mon Mar 10 1997 - 10:58:22 CST

Dear Sun Managers,
Thanks for the responses, many useful suggestions, but 10 seconds after
I posted my message, I worked it out!

Original message:

Dear Sun-managers,
> I need to ftp a file between two machines at a specified time each
> night. I can't put NFS or any 'R' commands on these machines for
> security reasons. So I need to get cron to execute a script which will
> automatically invoke ftp with the right parameters, and autologin and
> get the file and then exit. I have looked at the man pages, and they
> refer to macros, but they don't seem to be stored anywhere. Could any
> sun managers help me out here, all help will be acknowledged.

Thanks to all who replied.

Dave Staggs.
Ric Anderson.
Michael Clarkson.
Bert Shure.
Chris Barnard.
Mark Carey.

        The solution is of course to use a ~/.netrc file which contains
somthing like

machine login bill password microsoftsucks
#logs bill into '' with passwd microsoftsucks
macdef init #defines an ftp macro
cd pub

Thanks for the useful tips at: #great automation tool! #auto
mirrors ftp dirs. #public domain ftp server.

echo "user username passwd\nbinary\ncd /my_dir\nget my_file\n" | ftp -n
This redirects your the contents of the echo into ftp. This could be
useful as a start for longer scripts.....

Or here is a little perl if you need to build up some scripts....
This alows the use of variables, so that you could get or put files
according to
some set of conditions.

open FTP, "|/usr/bin/ftp >/dev/null 2>&1" || die "ERROR";
sleep 2;
print FTP "username_here\n"; sleep 1;
print FTP "password_here\n"; sleep 1;
print FTP "cd F:\n"; sleep 1;
print FTP "cd /scii/liveweb\n"; sleep 1;
print FTP "ascii\n"; sleep 1;
print FTP "put $sc2name liveweb.imp\n"; sleep 1;
print FTP "quit\n";

Thanks for the responses.

Simon Convey.

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:48 CDT