Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何在bash脚本中执行自定义命令_Linux_Bash_Shell_Terminal_Sh - Fatal编程技术网

Linux 如何在bash脚本中执行自定义命令

Linux 如何在bash脚本中执行自定义命令,linux,bash,shell,terminal,sh,Linux,Bash,Shell,Terminal,Sh,我想构建这样一个脚本: #!/bin/bash /path/to/my/program/myProgram MyCommand1 < — This is NOT a bash command MyCommand2 < — Neither is it #/bin/bash /路径/到/my/program/myProgram myCommand 1

我想构建这样一个脚本:

#!/bin/bash          
/path/to/my/program/myProgram
MyCommand1    < — This is NOT a bash command
MyCommand2    < — Neither is it
#/bin/bash
/路径/到/my/program/myProgram
myCommand 1<-这不是bash命令
MyCommand 2也不是
这些命令只能由我的程序的某种交互会话接受。你知道我该怎么做吗

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