【发布时间】:2012-03-24 16:19:21
【问题描述】:
我有一个场景,我需要在包含 log.txt 的远程计算机上列出 msystem 下的所有目录。如果找到,则使用 msystem 目录文件中的ll command 获取列表。如何实现这一点
这是目录结构
msystem
dir1 dir2/info/log.txt dir3/ dir4/info/log.txt
my $ssh = Net::SSH::Perl->new($hostname, protocol => '1,2', debug => 0, interactive => 1);
$ssh->login($username, $password);
($stdout,$stderr,$exit) = $ssh->cmd("$check_lock_file");
if((defined $stderr) && ($stderr =~ /No such file or directory/))
{
($stdout,$stderr,$exit) = $ssh->cmd("What command to be used and get the ouput");
if((defined $stderr) && ($stderr =~ /No such file or directory/))
{
print ""Error;
print "$stderr";
exit;
}
elsif($exit eq '0')
{
print "dir2 dir4";
}
}
【问题讨论】:
-
上面的代码有什么问题?它会出错吗?没有产生预期的结果?
-
你会如何在本地系统上使用
find? -
也许你可以参考stackoverflow.com/questions/2282686/…命令问题
标签: perl