I am trying to open multiple tabs and execute a series of commands in each tab. Lets say I open 3 tabs tab1, tab2, tab3. Then in each tab I would like to execute following:
ssh user@address (PublicKey Authentication is setup and hence no need to enter password)
Launch python scripts (python some.py)
Hold the tab open after executing the commands to see the outputs.
I went through some threads and have a rough outline for Bash script.
#!/bin/bash
echo "Script running"
gnome-terminal -e "bash -c \"ssh user@address; uname -a; exec bash\""
When I run the above script, a new terminal opens and I can see that I have ssh-ed into the target address but the other command uname -a
didnot execute.
I would like to build upon this to implement the following:
Open multiple tabs and run commands. Ex :
gnome-terminal --tab -e "bash -c \"ssh user@address; python file1.py; exec bash\"" -tab -e "bash -c \"ssh user@address; python file2.py; exec bash\""
Wait for one of the python file to start executing before opening another tab and repeating the process for another python file.
Also is there a better way to implement the same task ?
The above code snippet was from this thread.