Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
./a.out
请选择 1 或 2:
这会做一些事情
这会做其他事情
然后当我输入“1”时,它会完成它的工作。我没有代码本身,只有二进制,所以无法更改。我想编写一个运行 a.out 并在其中插入“1”的 shell 脚本。
./a.out 1
./a.out << 1
./a.out < 1
但不工作。能否请您告诉我是否有任何方法可以编写例如 shell 脚本?谢谢,dbm368
我想你只需要一根管子。例如:
echo 1 | ./a.out
一般而言,管道接受左侧程序写入的任何内容stdout并重定向到stdin右侧程序的。
stdout
stdin