1
我有一個場景,我需要列出包含log.txt的遠程計算機上的msystem下的所有目錄。如果找到,然後從msystem目錄文件中使用ll command
獲取列表。如何實現這一點 這是目錄結構在遠程計算機上查找Perl文件
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";
}
}
上面的代碼有什麼問題?它錯誤嗎?不會產生期望的結果? – DVK 2012-03-07 05:53:24
如何在具有'find'的本地系統上執行此操作? – 2012-03-07 08:30:36
也許你可以參考http://stackoverflow.com/questions/2282686/how-to-echo-directories-containing-matching-file-with-bash問題的命令 – 2012-03-07 11:02:55