Execute / send questions (C++) - WeOnlyDo Discussion board

Execute / send questions (C++) (General questions)

by Arun, Thursday, July 13, 2006, 22:01 (6707 days ago)

Environment: WodSsh.dll 2.4.1, c++(visual studio.net 2005), Win XP
Hi,

I have an application that does not know the prompt in advance and I need to find out the prompt before I do an Execute.

After all the WodSSh initializations I use the Send command like this: objSsh->Send( echo
);
Then I call the Receive command to get the string sent back.

From what I see... if I am debugging the program through VS then Receive gets me the entire response. For example: echo <crlf> bash-2.05$

But if I run the exe directly from the command line the Receive command only returns echo <crlf> !!
But if I put a _sleep(1000) it works (as the machines are in a local LAN). There is something fishy with the Receive method.

This is a surprising behavior as I thought Receive blocked till the entire string is received from the server. (I have set blocking = true).

Please advice how to fix this problem or if you have any sample code that can extract prompts from a response.

Thanks
Arun

Re: Execute / send questions (C++)

by wodDrazen, Thursday, July 13, 2006, 22:16 (6707 days ago) @ Arun

Hi Arun,


Sleep API isn't good idea, since it blocks same thread where wodSSH lives in.

You can try to use Regular expression

$ #>]

means it will accept any of those chars ($, ,#,>) if they appear at the end of the line. This includes 99.9 of most UNIX command prompts (including root account).

Here is example:
-----------------------------
Ssh1.WaitFor( regex:[$ #>] $ )
-----------------------------

Hope this helps.


Regards,
Drazen

Re: Execute / send questions (C++)

by Arun, Thursday, July 13, 2006, 22:50 (6707 days ago) @ wodDrazen

Thanks Drazen. I will try it out.