我曾尝试编写一个shell脚本,以便在多个终端中运行多个命令,但我无法运行这些命令,只能打开多个终端。这是在shell脚本文件sitl.sh中编写的。
#!/bin/bash
gnome-terminal --working-directory=/home/mit/catkin_ws/ && roslaunch iq_sim iris.launch && rosrun iq_gnc square
gnome-terminal --working-directory=/home/mit/ardupilot/ArduCopter/
gnome-terminal --working-directory=/home/mit/catkin_ws/
gnome-terminal --working-directory=/home/mit/catkin_ws/ && roslaunch iq_sim lidar.launch如果我运行这个脚本,命令在同一个终端上执行,如果我终止第一个命令,下一个命令正在运行,如果我终止第二个命令,第三个命令正在运行。我需要同时运行所有命令。我需要使用单个shell脚本命令同时在每个终端窗口中运行每个命令。请帮我解决这个问题。
我输出的目的是,需要运行多个命令,命令应该同时在每个终端单独执行,我不需要终止第一个命令,这样我的第二个命令就可以工作了。请帮我的朋友解决我的问题。
提前谢谢你。
致以敬意,
普拉文
发布于 2020-09-24 14:17:16
您应该使用选项-e或-x来进行gnome-terminal。根据man gnome-terminal的说法:
-e, --command=STRING
Execute the argument to this option inside the terminal.
-x, --execute
Execute the remainder of the command line inside the termi‐
nal.https://askubuntu.com/questions/1277384
复制相似问题