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

 测试脚本

@echo off
echo -----------------------开始了----------------------
set /p a1=请输入a1 & echo.
set /p a2=请输入a2 & echo.
set /p a3=请输入a3 & echo.
set /p a4=请输入a4 & echo.
set /p a5=请输入a5 & echo.

echo -----------------------结束了----------------------
echo a1=%a1%
echo a2=%a2%
echo a3=%a3%
echo a4=%a4%
echo a5=%a5%

pause

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

12-15 06:42