$ssh is Net::SSH::Expect object. The scenario is like, from my local machine i need to ssh to the test server. From test server i can ssh to other server under test and execute commands. So $ssh handle is for test server. Now from test server i am doing ssh to other machine and executing 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
The command execution is failing from perl script But when i Run the same command from command line it pass: following is the same command i am executing directly from the test server.
[root@ganesha36 ~]# ssh mgmt001st001 mkexport kas327134640 /ibm/gpfs0/kas327134640 --nfs "*\(rw,no_root_squash\)"
EFSSG0019I The export kas327134640 has been successfully created.
EFSSG1000I The command completed successfully.
Here are lines from script:
$cmd='ssh mgmt001st001 mkexport ' . $share_name . ' ' . $path . ' --nfs \'' . '\\*' . '\\(rw,no_root_squash\\)\'';
print "CMD: $cmd";
$out=$ssh->exec("$cmd");
print $out;
Here is the output:
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
I have change * to the client name working fine... but what's the problem with *
$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.
$ssh? Is it a Net::SSH::Expect object? They your commands are significantly different. In the command line version, you are executingmkexporton the remote host. In the Perl version, you ar executingsshon the remote hsot.