perl脚本:FTP获得服务器文件
发布时间:2020-12-15 21:03:31 所属栏目:大数据 来源:网络整理
导读:该脚本采用FTP方式从批量服务器上获得文件。 #!perl#Author: HC#Date: 2012/10/22use Net::FTP;use Cwd;$localFile = getcwd()."/log/";if (!-e $localFile){mkdir $localFile,0755 or warn "Cannot make $localFile directorty:$!";}if (!open SERVER_INFO,
该脚本采用FTP方式从批量服务器上获得文件。 #!perl #Author: HC #Date: 2012/10/22 use Net::FTP; use Cwd; $localFile = getcwd()."/log/"; if (!-e $localFile){ mkdir $localFile,0755 or warn "Cannot make $localFile directorty:$!"; } if (!open SERVER_INFO,getcwd()."/ftpserver.txt"){ die "Ftp server information file can not be found:$!"; } while (<SERVER_INFO>){ @fields = split; $serverName = $fields[0]; $server = $fields[1]; $port = $fields[2]; $user = $fields[3]; $pwd = $fields[4]; $remoteFile = $fields[5]; $ftp = Net::FTP->new($server,Port=>$port,Debug=>0,Timeout=>1000) or die "Cannot connect:$!"; $ftp->login($user,$pwd) or die "Could not login:$!"; $ftp->get($remoteFile,$localFile.$serverName.".log") or die "Could not get remote file:$remoteFile:$!"; print $serverName."Get file successful.n"; $ftp->quit; } print "Press <Enter> to continue..."; <>; system "start $localFile"; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |