0

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
liv2hak
  • 14,472
  • 53
  • 157
  • 270

1 Answers1

0

Try this to your bash script:

   #!/bin/sh

   gnome-terminal -x sudo ./home/karthik/mininet/my_topo.sh
vahnevileyes
  • 415
  • 3
  • 6