简体   繁体   English

如何在perl中的远程服务器上创建Zip文件

[英]How to create a Zip file on a remote server in perl

actualy im using Net::FTP::Recursive to download a directory structure , it works nice for what is required. 实际上我使用Net :: FTP ::递归下载目录结构,它适用于所需的。 But since some folders have more than 100/ files, downloading then can take ages. 但由于某些文件夹有超过100个/文件,因此下载可能需要很长时间。 Since a zip file is faster do download, how i could, using perl connect to a remote server via ftp and create a zip file from the remote server/folder to download ? 由于zip文件更快下载,我怎么可能,使用perl通过ftp连接到远程服务器并从远程服务器/文件夹创建一个zip文件下载?

use Net::Config;
use Net::FTP::Recursive;


$ftp = Net::FTP::Recursive->new("$hostname:$ftp_port",  Debug => 0)
or die "Cannot connect to $hostname: $@";
$ftp->login($iLogin,$iPass)
or die "failed ", $ftp->message;
$ftp->binary()
or die "Cannot set to Binary";
$ftp->cwd("/admin/packages/$fileName")
or die "Cannot change working directory ", $ftp->message;
$ftp->rget( $fileName );
#or die "Download Failed ", $ftp->message;
$ftp->quit;

Thank you all for your time 谢谢大家的时间

I think you'd need to have SSH access to the system to run a ZIP command. 我认为您需要具有SSH访问系统才能运行ZIP命令。 But if that's the case, you could also use SCP to transfer your files more securely. 但如果是这种情况,您也可以使用SCP更安全地传输文件。 FTP does everything in the open. FTP完成所有工作。

Thanks, 谢谢,

F. F。

The site(ARGS) method is designed for that. 站点(ARGS)方法就是为此而设计的。 You can send a shell command and make it runs on remote server. 您可以发送shell命令并使其在远程服务器上运行。 http://perldoc.perl.org/Net/FTP.html#METHODS http://perldoc.perl.org/Net/FTP.html#METHODS

However, most of the FTP servers I know disabled that permission, so, good luck 但是,我知道的大多数FTP服务器都禁用了该权限,所以,祝你好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM