cron to check ftp upload/download
Rick Stevens
rstevens at vitalstream.com
Mon Mar 21 21:18:25 UTC 2005
karlp at ourldsfamily.com wrote:
>>karlp at ourldsfamily.com wrote:
>>
>>>>can u tell me a little sort of script line that i will put in.
>>>>
>>>>wget ftp://tivimtech.com/*.* .......rest i do not know
>>>>how will i specify user name and password ? and will *.* download all
>>>>file
>>>>of ftp server in any folder?
>>>
>>>
>>>Frankly, I'd use ftp to do it and run a script like this one I wrote
>>>(you'll have to change the PUT to GET and any associated syntax):
>>>
>>>#!/bin/sh
>>>if [ "$6" = '' ] &&
>>> [ "$5" = '' ] &&
>>> [ "$4" = '' ] &&
>>> [ "$3" = '' ] &&
>>> [ "$2" = '' ] &&
>>> [ "$1" = '' ]
>>> then
>>> echo
>>> echo Usage: $0 DestHost USERNm PASSWd LocalPth2Dir RemotePth2Dir
>>>FNAME
>>> echo
>>> exit 1
>>>fi
>>>HOST=$1
>>>USERNM=$2
>>>PASSWD=$3
>>>LPATH=$4
>>>RPATH=$5
>>>FNAME=$6
>>>ftp -p -n $HOST 2>/dev/null <<- End_of_FTP_commands
>>>user $USERNM $PASSWD
>>>lcd $LPATH
>>>cd $RPATH
>>>put $FNAME
>>>End_of_FTP_commands
>>
>>Uh, how about:
>>
>>#!/bin/bash
>>if [ $# -lt 6 ]; then
>
>
> Duh.
> I'm not that far into any of the self-help books I'm learning from...
> Hey, it works. Thanks Rick.
No problem. "$#" returns the number of arguments passed to the script.
It does NOT count $0 (the script name itself). Also "$?" returns the
return code from the LAST program run. Generally, successful programs
return 0 and failures return non-zero, so:
RC=$? # Remember $? only works for the LAST program/script
if [ $RC -ne 0 ]; then
echo Program failed, return code $RC
else
echo Program succeeded\!
fi
is a way to see if it was successful or not. I assigned the value of $?
to RC because $? would be reset by the "if" statement itself.
>> echo
>> echo Usage: $0 remotehost username passwd localpath remotepath fname
>> echo
>> exit 1
>>fi
>>ncftpget -d /var/log/ncftpget.log -u $2 -p $3 $1 $4 $5/$6
>
>
> Not available on my server (AIX 4.3.3) and the Linux Toolbox isn't
> installed. With a new server nearly on order which WILL have the Linux
> toolbox, It'll be happening soon.
ncftpget can be had from http://www.ncftp.com/download/. There are
even precompiled binaries for AIX 4.3.3 on the RS/6000:
http://www.ncftp.com/ncftp/binaries/ncftp-3.1.8-aix4.3.3-export.tar.gz
I'd get the client for sure...it's a HUGE part of my toolkit.
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer rstevens at vitalstream.com -
- VitalStream, Inc. http://www.vitalstream.com -
- -
- UNIX is actually quite user friendly. The problem is that it's -
- just very picky of who its friends are! -
----------------------------------------------------------------------
More information about the Redhat-install-list
mailing list