Skip to content

How can I send the Ctrl+D command to stdin? #327

Answered by pkittenis
rodrigomologni asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there,

Your program probably expects an interactive shell to be available and can't read from stdin without one. So the interactive shell works but remote run which does not use an interactive shell does not.

You could also try run_command(<..>, use_pty=True) if it is a matter of the program requiring a TTY.

If the program requires an interactive shell, use open_shell. It depends on the program, ssh server, server config and so forth.

General advice is: if it works with ssh <host> <remote cmd> it will work with run_command. That is a non-interactive remote command.

If you need to ssh <host> then type something, use open_shell. That's an interactive shell.
ssh <host> << some script here…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rodrigomologni
Comment options

Answer selected by rodrigomologni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants