$ ssh是Net :: SSH :: Expect对象。场景就像从我的本地机器我需要ssh到测试服务器。从测试服务器我可以ssh到其他正在测试的服务器并执行命令。所以$ ssh句柄用于测试服务器。现在从测试服务器我正在ssh到其他机器并执行mkexport。
while($no_of_exports)
{
my $share_name = &get_share_name();
my $path="$fs" . "$share_name";
$cmd="ssh mgmt001st001 mkexport $share_name $path --nfs \"*\\(rw,no_root_squash\\)\"";
print "CMD: $cmd";
$out=$ssh->exec("$cmd");
print $out;
--$no_of_exports;
}
Output :
[root@ganesha36 ~]#
CMD: ssh mgmt001st001 mkexport kas142818597 /ibm/gpfs0/kas142818597 --nfs "*\(rw,no_root_squash\)"
97 --nfs "*\(rw,no_rxport kas142818597 /ibm/gpfs0/kas1428185
命令执行从perl脚本失败 但是当我从命令行运行相同的命令时,它传递: 以下是我直接从测试服务器执行的相同命令。
[root@ganesha36 ~]# ssh mgmt001st001 mkexport kas327134640 /ibm/gpfs0/kas327134640 --nfs "*\(rw,no_root_squash\)"
EFSSG0019I The export kas327134640 has been successfully created.
以下是来自剧本的行:
$cmd='ssh mgmt001st001 mkexport ' . $share_name . ' ' . $path . ' --nfs \'' . '\\*' . '\\(rw,no_root_squash\\)\'';
print "CMD: $cmd";
$out=$ssh->exec("$cmd");
print $out;
这是输出:
CMD: ssh mgmt001st001 mkexport kas522199075 /ibm/gpfs0/kas522199075 --nfs '\*\(rw,no_root_squash\)'
75 --nfs '\*\(rw,no_xport kas522199075 /ibm/gpfs0/kas5221990
> root_squash\)'
EFSSF1156A An error occurred in NFS configuration. The client syntax cannot be parsed. See "man exports" for help. Cause: *(rw,no_
bash: line 1: root_squash): command not found
我已将*更改为客户名称工作正常...但*
的问题是什么$cmd='ssh mgmt001st001 mkexport ' . $share_name . ' ' . $path . ' --nfs "' . 'client002' . '\\\\(rw,no_root_squash\\)"';
print "CMD: $cmd";
$out=$ssh->exec("$cmd");
print $out;
CMD: ssh mgmt001st001 mkexport kas482978105 /ibm/gpfs0/kas482978105 --nfs "client002\\(rw,no_root_squash\)"
05 --nfs "client002\xport kas482978105 /ibm/gpfs0/kas4829781
> \(rw,no_root_squash\)"
EFSSG0019I The export kas482978105 has been successfully created.
EFSSG1000I The command completed successfully.
答案 0 :(得分:1)
假设$ssh
是Net :: SSH :: Expect对象,您在命令行版本中正在远程主机上执行mkexport
,但您正在远程主机上执行ssh
托管在Perl版本中。反过来,由于未转义的*
,这会导致问题。
ssh mgmt001st001
。\\
。*