[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell command end check


On Wednesday 16 October 2013 08:22:39 Joao Pedro Almeida Pereira wrote:
> Hello,
> I am creating an application using libssh to connect against a remote
> server using the shell mode of the application.
> I need this to be shell like because i need to keep context of my location
> and keep my connection open in order to ensure that i pass through a
> process of initialization only once.
> This takes me to a next problem, when i send a command via SSH the
> application need to be aware when the command finished executing and as i
> do not close the connection in the end nor i do a oneshot command i do not
> receive the EOF to tell me that the execution ended.
> How can i do this?
> 
> I came up with 2 solutions for this problem and i dislike both of them:
> 1. retrieve the pty in order to be able to search the output for the prompt.
> This is not a good solution for me because my application will be be
> connecting against 4 distinct shell's that will have multiple prompts
> possible, and each shell can change is prompt.
> 2. Send a "random" string, like a command, after my command and check the
> output for the return of that string.
>      This is not a good solution because i need to parse all the output to
> find the end and my output is quite big for some commands that i will be
> executing and that will penalize the command execution
> 

./myapplication && echo OK || echo KO

Is normally the way to do it.



	-- andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx


Follow-Ups:
Re: Shell command end checkJoao Pedro Almeida Pereira <joao.almeida@xxxxxxxxxxx>
References:
Shell command end checkJoao Pedro Almeida Pereira <joao.almeida@xxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org