Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux bashshell脚本,如何编写脚本来运行请求输入的程序?_Linux_Bash_Shell - Fatal编程技术网

Linux bashshell脚本,如何编写脚本来运行请求输入的程序?

Linux bashshell脚本,如何编写脚本来运行请求输入的程序?,linux,bash,shell,Linux,Bash,Shell,我有一个程序,porodry,它需要读取一个参数文件才能运行,假设文件名为test1,那么如果我使用bash 我能跑 ./porodry 航站楼将显示: please input your parameters file name: 我会打字 test1 然后程序开始运行,并在终端上显示一些输出,如 Please input an int number: 然后我将键入如下内容: 1110 然后程序将继续运行 我想写一个脚本,它将自动读取输入并将终端内容输出到test1.terminal

我有一个程序,
porodry
,它需要读取一个参数文件才能运行,假设文件名为
test1
,那么如果我使用bash

我能跑

./porodry
航站楼将显示:

please input your parameters file name:
我会打字

test1
然后程序开始运行,并在终端上显示一些输出,如

Please input an int number:
然后我将键入如下内容:

1110
然后程序将继续运行

我想写一个脚本,它将自动读取输入并将终端内容输出到
test1.terminal
文件


请帮帮我

这取决于程序的实际功能。如果它只是从标准输入中读取,您只需通过管道将输入传输到它,并将输出重定向到一个文件:

echo test1 | ./porodry > test1.terminal

如果终端出现问题,您可能需要
expect

谢谢,您的脚本可以运行,但我忘记了一件事,不仅有一个输入,还有另一个输入,请再次帮助。谢谢。@user43506:请尝试
{echo test1;echo input2;}|./porodry>test1。终端
。谢谢,它正在使用中