I am currently in my Project directory.
$ pwd
/home/karthik/Projects
I do the following from the cmdline.
gnome-terminal --tab --working-directory="/home/karthik/mininet" -e "sudo ./my_topo.sh"
I expect the above command to do the following
1) open a tab
2) go to working directory `/home/karthik/mininet`
3) execute the script `my_topo.sh`
Instead it seems to do the following.
1) open a terminal.
2) go to working directory `/home/karthik/mininet`
3) execute the script `my_topo.sh`
Also on a related note,How do I open a tab with sudo privileges so that I don't have to type in my password?
I tried doing the following
WID= xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}'; xdotool windowfocus $WID; xdotool key ctrl+shift+t $WID
This does open a new tab but how do I execute the following commands in the new tab instead of the old one.
cd /home/karthik/mininet;
sudo ./my_topo.sh
Try this to your bash script:
#!/bin/sh
gnome-terminal -x sudo ./home/karthik/mininet/my_topo.sh
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.