直接将文件下载到FTP服务器

时间:2012-09-24 06:53:01

标签: perl ubuntu wget

我想从普通的http-link下载一个大文件到ftp-server(在ubuntu下)而不在本地存储文件(因为我的本地存储空间太小)。

你对wget或一个小的perl脚本有什么想法吗? (我在本地机器上没有sudo权限。)

4 个答案:

答案 0 :(得分:2)

这是我的看法,在命令行上合并了wgetNet::FTP

wget -O - http://website.com/hugefile.zip | perl -MNet::FTP -e 'my $ftp = Net::FTP->new("ftp.example.com"); $ftp->login("user", "pass"); $ftp->put(\*STDIN, "hugefile.zip");'

当然,您也可以将其放在文件(ftpupload.pl)中并运行它。

#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;

my $ftp = Net::FTP->new("ftp.example.com"); # connect to FTP server
$ftp->login("user", "pass"); # login with your credentials

# Because of the pipe we get the file content on STDIN
# Net::FTP's put is able to handle a pipe as well as a filehandle
$ftp->put(\*STDIN, "hugefile.zip");

像这样运行:

wget -O - http://website.com/hugefile.zip | perl ftpupload.pl

答案 1 :(得分:1)

当然 - 有一个CPAN模块可以让FTP变得简单:

http://search.cpan.org/search?mode=module&query=Net%3A%3AFTP

WWW :: Mechanize查找文件,跟踪链接等。

通过这些模块,我认为您可以解决您的问题。

答案 2 :(得分:1)

您可以尝试使用wput。它不是很有名的工具,但我认为你可以使用它。

答案 3 :(得分:0)

使用wget的输出文档选项

wget -O /dev/null http://foo.com/file.uuu

从wget的手册页:

"-O file
       --output-document=file
           The documents will not be written to the appropriate files, but all will be
concatenated together and written to file.  If - is used as file, documents will be
printed to standard output, disabling link conversion.  (Use ./- to print to a file 
literally named -.)

       Use of -O is not intended to mean simply "use the name file instead of the 
one in the URL;" rather, it is analogous to shell redirection: wget -O file http://foo is
intended to work like wget -O - http://foo > file; file will be truncated immediately, 
and all downloaded content will be written there."

但是,我看不出那个

的目的是什么
相关问题