Re: ssh cmd vs ssh shell (676 Views)
Reply
Occasional Contributor
Lim Swee Aun
Posts: 9
Registered: ‎06-06-2010
Message 1 of 4 (702 Views)
Accepted Solution

ssh cmd vs ssh shell

[ Edited ]

Hi,

 

Two questions around usage of  SSH Command and SSH Shell

(Library -> Operations -> Remote Command Execution -> SSH)

 

1. SSH Command vs SSH Shell

=========================

Command "test.sh" runs using putty and produces an xml response.

- when using SSH Command (providing inputs for host, username, password, command = test.sh)

- command does not execute, operation fails with "command not found"

- running "ls -l", "pwd" using this same step works well

 

- when using SSH Login, followed by SSH SSH shell, this same "test.sh" runs ok.

 

Question: anyone can explain why the different behavior?

 

2. SSH Shell does not capture the command response

The commands in my SSH Shell command field:

     send test.sh

     expect (.*\s*)*?

The command runs but the output is not captured by OO operation

(I need the response in order to process further)

 

Question: how to capture ssh shell command output? Seems like what I did above is wrong.

 

Thanks for your help

 

swee-aun.lim@hp.com

BSA presales, Singapore

 

Trusted Contributor
ntt00015
Posts: 91
Registered: ‎09-18-2011
Message 2 of 4 (694 Views)

Re: ssh cmd vs ssh shell

Hi,

 

First of all I am not sure which version of OO you are using but I assume that you are using 9.02 or higher.

Secondly whats the version of your RAS machine? I assume its a Unix machine.

 

When you use SSH Command be sure that you gave the full path of the script file. And be sure the user that you login with has the executable right(chmod 7xx) for the script file. 

I think the script file is in another folder so when you run test.sh with "SSH Command" operation you get the "command not found" error.

Try this command  " cd ../foldername_that_script_file_exist ; ./test.sh " in the SSH Command operation.

 

 

"SSH Shell" operation captures the responses successfully. There might be something wrong in your command lines.

Here is my command example:

 

send . ~/.profile ; cd /folder1/folder2/subfolder
expect (.*\s*)*/folder1/folder2/subfolder>
send grep "/${command_text}" ${command_list_file}
expect (.*\s*)*/folder1/folder2/subfolder>

 

First I am setting my profile settings and getting into a folder with cd command. "cd /folder1/folder2/subfolder" (First Row)

For waiting the prompt line expects my new command I am expecting the "/folder1/folder2/subfolder>" string on the screen. (Second Row)

WithThird Row I am sending a new command (grep) with my parameters.

And at last I am waiting for the command ends and to see the result(Fourth Row). It is expecting the "/folder1/folder2/subfolder>" string on the prompt line again.

After the commands end, you can get the output results in the operation.

 

I hope it gives a hint and sparks your mind. :)

Best Regards.

 

Occasional Contributor
Lim Swee Aun
Posts: 9
Registered: ‎06-06-2010
Message 3 of 4 (688 Views)

Re: ssh cmd vs ssh shell

Thanks for your help.

 

More info:

- OO 9.02 with CP6

- on Windows 2003 (Windows RAS)

 

Does this mean I need to use a different ssh shell operation (SSH (Windows RAS)?

 

 

Your examples is very good.  Is there a place or doc I can find more examples?

 

Sincerely,

SweeAun

Trusted Contributor
ntt00015
Posts: 91
Registered: ‎09-18-2011
Message 4 of 4 (676 Views)

Re: ssh cmd vs ssh shell

Hi,

 

Even if you have a windows RAS , there is no need to be use different operation. The main point is the host machine's SSH port is working properly. 

 

Actually I don't know if there is any document that explains these details. I am only reading the operation's descriptions. If I do not understand properly I check the Authors Guide and the SDK Guide to find some clues about operations. 

 

 

Regards.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.