Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Identifying that a command has finished (ShellStream)

$
0
0
I didn't realize you were simply attempting to respond to the prompts. I thought you were trying to figure out when the whole program had finished executing.

The Channel_DataReceived() bit is good to know.

FWIW, some other ideas to consider in future cases:

I expect that because how the typical read command is done that the code could send data down the pipe whenever and it would simply buffer on stdin until the process in question looked for it (reading it in and processing the input one line at a time regardless of how many lines were "prequeued").

For example, if the code executed shellStream.Write("interactive_command.sh\nmy first string\nmysecond string\n") as one command, I'd expect it to work.
Or something like: echo "my first line\nmy second line" | interactive_command.sh # (Assuming a real terminal, it could be echo, echo -e, or printf to get the newline)
Or put the commands in a file and execute: interactive_command.sh < file_with_commands_to_input_on_multiple_lines

There are some circumstances where these techniques might not work; for example when a script goes out of its way to clear all things in the buffer before prompting or when the script attempts to do direct raw character reading. But those kinds of scripts seem rather rare.

Regardless though I'm pleased to hear you got a solution that worked for you!

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>