簡體   English   中英

在Ubuntu上使用gnome-terminal --tab選項打開一個選項卡並運行腳本

[英]open a tab and running a script using gnome-terminal --tab option on Ubuntu

我目前在我的Project目錄中。

$ 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

在您的bash腳本中嘗試以下操作:

   #!/bin/sh

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM