0
如果我有一个命令行程序作为与命令行交互的后台线程(与./程序&一起执行)执行,我如何向它发送命令?有没有一种方法(比如使用'pipe')发送字符,就像它们在命令行中输入一样?将按键发送到后台应用程序
简化的命令行示例:
没有&(正常情况下):
~/home/temp> ./testprogram
~/home/temp> Welcome to Testprogram. Enter command:
~/home/temp> Welcome to Testprogram. Enter command: quit
~/home/temp> Goodbye!
随着&:
~/home/temp> ./testprogram &
~/home/temp> Welcome to Testprogram. Enter command:
~/home/temp> quit
~/home/temp> Command not found.
一个PS -e |(我的情况!) grep testprogram显示它仍在运行,但现在不能在'kill'命令之外终止。
什么是理想的是类似如下:
究竟如何做到这一点?