ftp script?

Rick Stevens rstevens at vitalstream.com
Wed Dec 15 00:55:29 UTC 2004


karlp at ourldsfamily.com wrote:
>>IT WORKS!!!
>>
>>Thanks!
>>
>>Harold
> 
> 
> Good to listen to Rick. But what about when you are on a *nix system that
> doesn't have ncftp? In that case, you can roll your own, as I have in this
> version which actually works, in spite of the author:
> 
> ~/bin/ftp_put:
> 
> #!/usr/bin/ksh
> # Karl Pearson
> # This version written for AIX but should work on other platforms
> if [ "$6" = '' -o "$5" = '' -o "$4" = '' -o "$3" = '' -o "$2" = '' -o "$1"
> = '' ] ; then
>   echo
>   echo Usage: ftp_put RemoteHOST USERName PASSWord LocalPATH RemotePATH
> FileNAME  echo
>   exit 0
> fi
> # Reassign variable names
> HOST=$1
> USERNM=$2
> PASSWD=$3
> LPATH=$4
> RPATH=$5
> FNAME=$6
> # execute command
> ftp -n  $HOST 2>/dev/null  <<- EOCMDS
> user $USERNM $PASSWD
> lcd $LPATH
> cd $RPATH
> put $FNAME
> EOCMDS

Perfectly valid, Karl.  The only problem with it is it won't handle
errors and it only handles one file at a time.  In a pinch, it'll
sure work and is pretty darned elegant at that.

ncftp* is open source and will build on near anything with a C
compiler on it--including Winblows.  Another option is to use perl
(perl has FTP support).

>>>Harold Hallikainen wrote:
>>>
>>>>I'm trying to have ftp send a file to another machine in a shell script
>>>>called by cron. After Googling around, reading various man pages, etc.,
>>>>it looks like I've gotten the script to log in properly by setting up
>>>>stuff in .netrc , but I'm still having trouble sending the cd and put
>>>>commands into ftp from the script. Can anyone give me some clues? This
>>>>is running on an RH8 machine.
>>>
>>>Have a look at the "ncftpput" and "ncftpget" commands.  They are
>>>FTP client programs specifically written to be used in batch or shell
>>>scripts.  "man ncftpput" and "man ncftpget" for details.
>>>----------------------------------------------------------------------
>>>- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
>>>- VitalStream, Inc.                       http://www.vitalstream.com -
>>>-                                                                    -
>>>-    First Law of Work:                                              -
>>>-    If you can't get it done in the first 24 hours, work nights.    -
>>>----------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Redhat-install-list mailing list
> Redhat-install-list at redhat.com
> https://www.redhat.com/mailman/listinfo/redhat-install-list
> To Unsubscribe Go To ABOVE URL or send a message to:
> redhat-install-list-request at redhat.com
> Subject: unsubscribe
> 


-- 
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
- Linux is like a wigwam...no windows, no gates...and apache inside! -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list