如何使用Perl检查远程服务器上是否存在文件?
发布时间:2020-12-15 23:32:56 所属栏目:大数据 来源:网络整理
导读:如何使用Perl检查远程服务器上是否存在文件? 我可以在使用Perl模块Net :: FTP时执行此操作吗? 检查是否存在文件 if (-e $file_check) { print "File Exists!n"; } else { print "File Doesn't Exist!n"; } 解决方法 使用SSH执行此操作可能是最好的服务:
|
如何使用Perl检查远程服务器上是否存在文件?
我可以在使用Perl模块Net :: FTP时执行此操作吗? 检查是否存在文件 if (-e $file_check) {
print "File Exists!n";
}
else {
print "File Doesn't Exist!n";
}
解决方法
使用SSH执行此操作可能是最好的服务:
#!/usr/bin/perl
use strict;
use warnings;
my $ssh = "/usr/bin/ssh";
my $host = "localhost";
my $test = "/usr/bin/test";
my $file = shift;
system $ssh,$host,$test,"-e",$file;
my $rc = $? >> 8;
if ($rc) {
print "file $file doesn't exist on $hostn";
} else {
print "file $file exists on $hostn";
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
