Yogesh
Yogesh

Reputation: 49

Executing a shell script to run python script remotely but not stopping for prompts

Executing a python script located on a remote machine. Python script prompts to ask for the option. While running using the following code, execution finishes with stopping/pausing for the prompt.

ssh -t [email protected] << EOF
    python script.py --user username --password pwrd --option xyzlmn
EOF

Upvotes: 0

Views: 103

Answers (1)

jhnc
jhnc

Reputation: 16819

Your python script wants to read from its stdin.

It obtains its stdin from ssh.

ssh has been set so that its stdin is the heredoc (EOF..EOF).

So python attempts to read from the heredoc but there is nothing to read.

Pass the python command as arguments to ssh instead, so that ssh's stdin is still the tty:

ssh [email protected] '
    python script.py --user username --password pwrd --option xyzlmn
'

Upvotes: 1

Related Questions