1

$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.
5
  • How is the script run when you not run it manually? How is it failing? Any error messages/log entries? Commented Jul 23, 2012 at 16:24
  • looks like it is a buffer problem. the output of the script is showing CMD: ssh mgmt001st001 mkexport kas326656126 /ibm/gpfs0/kas326656126 --nfs "*(rw,no_root_squash)" 26 --nfs "*(rw,no_rxport kas326656126 /ibm/gpfs0/kas3266561 > oot_squash)" / EFSSF1156A An error occurred in NFS configuration. The client syntax cannot be parsed. See "man exports" for help. Cause: *(rw,no_r bash: line 1: oot_squash): command not found Commented Jul 23, 2012 at 16:44
  • 1
    What is $ssh? Is it a Net::SSH::Expect object? They your commands are significantly different. In the command line version, you are executing mkexport on the remote host. In the Perl version, you ar executing ssh on the remote hsot. Commented Jul 23, 2012 at 18:11
  • yes $ssh is Net::SSH::Expect object. No in both the cases i am executing ssh in the remote host. The scenario is like this. 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 command. So $ssh handle is for test server. Now from test server i am doing ssh to other machine and executing mkexport. Commented Jul 24, 2012 at 2:22
  • 1
    What you've just said and what you posted in your post are different. Please fix the one that wrong. I'll take the actual code and session transcript over your word, especially when I can replicate your problem. Commented Jul 24, 2012 at 6:32

1 Answer 1

1

Assuming $ssh is a Net::SSH::Expect object, you are executing mkexport on the remote host in the command line version, but you are executing ssh on the remote host in the Perl version. This, in turn, leads to problems due to the unescaped *.

  • Remove the extraneous ssh mgmt001st001.
  • Add \\ in front of the *.
Sign up to request clarification or add additional context in comments.

1 Comment

I have addedd the lines from script and it's output after making changes to i.e adding \\ in front of *

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.