4
第一次迭代中相同的命令失敗,但傳入第二次迭代。有時它會通過兩次迭代。 $ssh
是Net::SSH::Expect
的對象。 這種奇怪的行爲的任何想法?間歇性第一次迭代失敗,但第二次迭代通過
$ssh = Net::SSH::Expect->new(
host => "$host",
password => "$pass",
user => "$id",
raw_pty => 1,
timeout => 50
);
代碼段:
&Test("Create exports on Sonas------ No Kerberos");
$no_of_exports=2;
my $fs = "/ibm/gpfs0/";
while($no_of_exports)
{
my $share_name = &get_share_name();
my $path="$fs" . "$share_name";
$cmd="ssh mgmt001st001 mkexport $share_name $path --nfs 'client002\\\\(rw,no_root_squash\\)'";
print "CMD: $cmd";
$out=$ssh->exec("$cmd");
print $out;
--$no_of_exports;
}
輸出:
Test 02 : Create exports on *Sonas*------ No Kerberos
CMD: ssh mgmt001st001 mkexport kas41535108 /ibm/gpfs0/kas41535108 --nfs 'client002\\ (rw,no_root_squash\)'
--nfs 'client002\\(xport kas41535108 /ibm/gpfs0/kas41535108
> rw,no_root_squash\)'
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `mkexport kas41535108 /ibm/gpfs0/kas41535108 --nfs client002\\('
[[email protected] ~]#
[[email protected] ~]#
CMD: ssh mgmt001st001 mkexport kas219760489 /ibm/gpfs0/kas219760489 --nfs 'client002\\ (rw,no_root_squash\)'
89 --nfs 'client002\xport kas219760489 /ibm/gpfs0/kas2197604
> \(rw,no_root_squash\)'
EFSSG0019I The export kas219760489 has been successfully created.
EFSSG1000I The command completed successfully.
你實例化你的Net :: SSH ::期待'raw_pty'模式對象? – DavidO 2012-07-24 07:19:56
是的,現在在我的問題中也添加了這個部分。 – Joe 2012-07-24 07:21:51
爲什麼在括號之前有'\\\\'?除非我錯過了一些東西,否則應該是'\\'(沒有空格)。 – 2012-07-24 07:27:15