Previously, I have used Tk/Expect along with plink (PuTTY) to automate remote shell operations. However, Expect sometimes fails if different shells have different prompts, or if prompt characters appear in non-prompt shell output (!)
I want to know if there is a way to tell if a remote shell is expecting input, either through plink, or some third party library. I am okay programming at the sockets layer if necessary.
No, there is no way to reliably detect a shell prompt at the level you’re working at. Some alternative options might be:
doSomething ; echo uniqueStringThatMeansThatWeAreDone— then search for that string.execthe one you want.Use a SSH library which can execute commands directly, rather than trying to script a shell. I’m not familiar with what’s available in Tcl, but Perl has
Net::SSH::Perl, which will let you do things like: