简体   繁体   English

执行shell脚本以远程运行python脚本,但不停止提示

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

Executing a python script located on a remote machine. 执行位于远程计算机上的python脚本。 Python script prompts to ask for the option. Python脚本提示询问该选项。 While running using the following code, execution finishes with stopping/pausing for the prompt. 使用以下代码运行时,执行将以停止/暂停提示结束。

ssh -t xyz@111.111.111.111 << EOF
    python script.py --user username --password pwrd --option xyzlmn
EOF

Your python script wants to read from its stdin. 您的python脚本要从其stdin中读取。

It obtains its stdin from ssh. 它从ssh获取其stdin。

ssh has been set so that its stdin is the heredoc (EOF..EOF). 已设置ssh,使其标准输入为heredoc(EOF..EOF)。

So python attempts to read from the heredoc but there is nothing to read. 因此,python尝试从heredoc中读取内容,但没有任何内容可供读取。

Pass the python command as arguments to ssh instead, so that ssh's stdin is still the tty: 将python命令作为参数传递给ssh,这样ssh的stdin仍然是tty:

ssh xyz@111.111.111.111 '
    python script.py --user username --password pwrd --option xyzlmn
'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM