[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] FTP download?



<snip>


> Hi,
>
> I am making something, stupid script :P
> But I was wondering... Is it possible with FTP, to download a file from
one
> raq to the other?
> I tried with wget, but that doesn't work... Unless I put it in a web
> accessable directory, then it might... But for security reasons that is
not
> very ok :D
>
> What I mean is like a ONE LINE command line, which could be used in a cron
> job, to get /root/FILE.tar.gz from SERVER#1...
>
> ANYONE have a clue? I ran out of idea's after trying for a few hours...
<snip>

This is not one line but a ftp-sub.. Should work on a sunday eve using perl
and the Net:"ftp module and/or a cron with it..
You might want some error and whatever depending... Best I could do by
memory...d'oh.
#!perlwhatever...
# start ftp_file
&ftp_file; # the call to action
#
sub ftp_file {
use Net::FTP;
# ftp configurables...
my $server     = "$ftphost";              # server to ftp to
my $user       = "$user";                 # username for ftp
my $pass       = "$pass";                 # password for ftp
my $dir        = "$remote_dir";           # directory to put file in
my $newer_file = "$new_file";             # local file to transfer
my $older_file = "$rem_file";             # remote file to remove
#
my $objFTP;                               # ftp object handle
#
$objFTP = Net::FTP->new("$server");       # connect
$objFTP->login("$user","$pass");          # login
$objFTP->cwd("$dir");                     # change dir
$objFTP->delete($older_file);             # delete existing
$objFTP->ascii();                         # send in ascii mode
$objFTP->put("$newer_file");              # send file
$objFTP->quit;                            # disconnect
}
# end ftp_file

David