私は、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
'find'を使ってローカルシステム上でどうやってやりますか? –
多分あなたはコマンドについてhttp://stackoverflow.com/questions/2282686/how-to-echo-directories-containing-matching-file-with-bashの質問を参照することができます –