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

Shell command end check

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

Isn't there a "automatic" way to do this inside the library?

Best Regards

João Pereira

Email: joao.almeida@xxxxxxxxxxx
Web: http://www.bluetc.es

Re: Shell command end checkAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org