我想编写一个shell脚本,用于运行一个需要接收原始输入的python文件。该python脚本大致如下:
def main():
name=raw_input("What's your name?")
print "Hello, "+name
main()
我希望shell脚本能够运行脚本并自动输入。我看到很多获取shell输入的方法,如从python函数返回值中获取,或者如何通过python运行带有输入的shell脚本,但没有这样的方法。基本上,我只是想要一个这样的东西:
python hello.py
# give the python script some input here
# then continue on with the shell script.
echo "read this!" | python hello.py
- moooeeeep