如何在 bash 脚本中执行自定义命令
How to execute custom command in bash script
我想构建这样的脚本:
#!/bin/bash
/path/to/my/program/myProgram
MyCommand1 < — This is NOT a bash command
MyCommand2 < — Neither is it
这些命令只能由我的程序的某种交互式会话接受。我该怎么做?
echo -e "MyCommand1\nMyCommand2"| /path/to/my/program/myProgram
或
/path/to/my/program/myProgram << EOF
MyCommand1
MyCommand2
EOF
如果你想在输入中有一些延迟,试试这个:
(sleep 2; echo "MyCommand1"; sleep 1; echo "MyCommand2") | /path/to/my/program/myProgram
我想构建这样的脚本:
#!/bin/bash
/path/to/my/program/myProgram
MyCommand1 < — This is NOT a bash command
MyCommand2 < — Neither is it
这些命令只能由我的程序的某种交互式会话接受。我该怎么做?
echo -e "MyCommand1\nMyCommand2"| /path/to/my/program/myProgram
或
/path/to/my/program/myProgram << EOF
MyCommand1
MyCommand2
EOF
如果你想在输入中有一些延迟,试试这个:
(sleep 2; echo "MyCommand1"; sleep 1; echo "MyCommand2") | /path/to/my/program/myProgram