SBernardo Absent Member.
Absent Member.
981 views

Going crazy with SSH Shell

Jump to solution

Hi all,

I'm using:

 /Base [1.8.0]/Library/Operations/Remote Command Execution/SSH/v2.0/SSH Shell    // HP OO 10.50 Linux

I'm trying to interact with a Linux server, but I cannot get my "expect" expression to work as expected.
It seems to me that the regular expression is running on the "sent command" itself and not on the server output.

I reduced my problem to the most simple absurd explained below... maybe the absurd in on myself 😉  I apreciate any help.

 

TEST A - Confirm the server response:

Sent command:

-------------------
send echo 'TEST''aa';
expect .*
-------------------

Flow completes with no error. This specific step return this "Primary Result":


-------------------
echo 'TEST''aa';
$ echo 'TEST''aa';
TESTaa
$
-------------------

I check that the output of my command is the string "TESTaa". All fine here.

 

TEST B - Expect for my string "TESTaa";

This is the command I'm sending:

-------------------
send echo 'TEST''aa';
expect .*TESTaa.*
-------------------

Error o get:

-------------------
exception=com.hp.oo.content.ssh.exceptions.SSHException: Script did not fully finish, had: 1 commands left java.lang.Exception: readTimedout at: 20037ms
-------------------

Seems like my string "TESTaa" - command output - was never found.

 

TEST C - Expect for string "echo":

Sent command:

-------------------
send echo 'TEST''aa';
expect .*echo.*
-------------------

Flow completes with no error.

 

My conclusion: expect regexp is running on sent command and not on server output. What am I doing wrong?

 

Thank you very  much.
Sergio Bernardo

Labels (1)
Tags (1)
0 Likes
1 Solution

Accepted Solutions
Trusted Contributor.. jarodb Trusted Contributor..
Trusted Contributor..

Re: Going crazy with SSH Shell

Jump to solution

Try

expectEndsWith $
send echo 'TEST''aa';

expect TESTaa
//or if you dont care to expect the result but want to see the prompt is returned

expectEndsWith $
send echo 'TEST''aa';
expectEndsWith $

//Actively seeking HPOO opportunities
0 Likes
1 Reply
Trusted Contributor.. jarodb Trusted Contributor..
Trusted Contributor..

Re: Going crazy with SSH Shell

Jump to solution

Try

expectEndsWith $
send echo 'TEST''aa';

expect TESTaa
//or if you dont care to expect the result but want to see the prompt is returned

expectEndsWith $
send echo 'TEST''aa';
expectEndsWith $

//Actively seeking HPOO opportunities
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.