ftp script?

karlp at ourldsfamily.com karlp at ourldsfamily.com
Tue Dec 14 21:59:55 UTC 2004


> 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


>> 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.    -
>> ----------------------------------------------------------------------





More information about the Redhat-install-list mailing list