使用Python的sh
,我正在运行第三方shell脚本,它请求我的输入(这并不重要,但准确地说,我运行的是带有--step
选项的Ansible2剧本)
作为对正在发生的事情的过度简化,我构建了一个请求输入的简单bash脚本。我相信,如果让这个简单的例子起作用,我也能使原来的案例也能起作用。在
所以请考虑这个bash脚本你好.sh公司名称:
#!/bin/bash
echo "Please input your name and press Enter:"
read name
echo "Hello $name"
我可以使用sh
模块从python运行它,但是它无法接收我的输入。。。在
我该怎么做?在
在遵循this tutorial之后,这对我的用例有效:
例如,输出为:
^{pr2}$有两种方法可以解决这个问题:
在中使用_,我们可以传递一个可以作为python脚本输入的列表
相关问题 更多 >
编程相关推荐