1. 程式人生 > >ubuntu下 利用sh檔案實現在多個終端下快速執行命令

ubuntu下 利用sh檔案實現在多個終端下快速執行命令

     ubuntu下,啟動一個程式可能需要開啟多個終端輸入多次命令,反正我覺得這樣是太麻煩了,寫了個sh檔案,直接執行就號了,需要注意的是,一定要給寫好的sh檔案足夠的許可權:

sudo chmod -R 777 xxx.sh

下面給個demo:
#!/bin/bash

source ~/catkin_ws1/devel/setup.bash
{
gnome-terminal -t "XXD_ros" -x bash -c "roscore;exec bash"
}&

sleep 1s
{
gnome-terminal -t "XXD_ms" -x bash -c "rosrun loitor_stereo_visensor loitor_stereo_visensor /home/zjd/catkin_ws1/src/loitor_stereo_visensor/Loitor_VISensor_Setups.txt;exec bash"
}&

sleep 1s
{
gnome-terminal -t "XXD_cam0" -x bash -c "rosrun image_view image_view image:=/cam0/image_raw;exec bash"
}&

sleep 1s
{
gnome-terminal -t "XXD_cam1" -x bash -c "rosrun image_view image_view image:=/cam1/image_raw;exec bash"
}&

sleep 1s
{
gnome-terminal -t "XXD_imu" -x bash -c "rostopic echo /imu0;exec bash"
}&

sleep 10s
{
gnome-terminal -t "XXD_record" -x bash -c "cd;rosbag record /cam0/image_raw /cam1/image_raw /imu0;exec bash"
}&
#{
#gnome-terminal -t "XXD1" -x bash -c "sh /home/laoxia/total_shells/show_img1.sh;exec bash"
#}&

   拿走,不謝!