脚本内调用交互程序传参的几种实现方式

老子叫甜甜 提交于 2019-12-06 04:56:14

1 windows 

 

echo param1>param.txt
echo param2>>param.txt
echo param3>>param.txt

call interactive.cmd < param.txt
pause

 最简单的

(echo input1 && echo input2) | program.exe

 

2 linux

/usr/bin/printf 'param1\nparam2\n' | mytestapp

 

 

 

 

参考文档

https://unix.stackexchange.com/questions/288765/using-a-bash-script-to-run-an-interactive-program

http://www.tldp.org/LDP/abs/html/here-docs.html

call与start区别

3https://stackoverflow.com/questions/2607856/several-ways-to-call-a-windows-batch-file-from-another-one-or-from-prompt-which

Automatically answer to input prompt in windows batch

https://stackoverflow.com/questions/40610241/automatically-answer-to-input-prompt-in-windows-batch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!