【问题标题】:open a tab and running a script using gnome-terminal --tab option on Ubuntu在 Ubuntu 上使用 gnome-terminal --tab 选项打开一个选项卡并运行脚本
【发布时间】:2014-02-06 00:41:47
【问题描述】:

我目前在我的项目目录中。

$ pwd

/home/karthik/Projects

我从 cmdline 执行以下操作。

gnome-terminal --tab --working-directory="/home/karthik/mininet" -e  "sudo ./my_topo.sh"

我希望上面的命令执行以下操作

1) open a tab 
2) go to working directory `/home/karthik/mininet`
3) execute the script `my_topo.sh`

相反,它似乎做了以下事情。

1) open a terminal. 
2) go to working directory `/home/karthik/mininet`
3) execute the script `my_topo.sh`

另外在相关说明中,如何打开具有 sudo 权限的选项卡,这样我就不必输入密码?

我尝试了以下操作

WID= xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}'; xdotool windowfocus $WID; xdotool key ctrl+shift+t $WID

这确实会打开一个新选项卡,但是如何在新选项卡而不是旧选项卡中执行以下命令。

cd /home/karthik/mininet;
sudo ./my_topo.sh

【问题讨论】:

标签: linux bash ubuntu sudo gnome-terminal


【解决方案1】:

在你的 bash 脚本中试试这个:

   #!/bin/sh

   gnome-terminal -x sudo ./home/karthik/mininet/my_topo.sh

【讨论】:

    猜你喜欢
    • 2013-10-29
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-26
    • 1970-01-01
    相关资源
    最近更新 更多