Avoid gnome-terminal close after script execution?

Viewed 72994

I created a bash script that opens several gnome-terminals, connect to classroom computers via ssh and run a script.

How can I avoid that the gnome-terminal closes after the script is finished? Note that I also want to be able to enter further commands in the terminal.

Here is an example of my code:

gnome-terminal -e "ssh root@<ip> cd /tmp && ls"
10 Answers

Finally this one works for me:

gnome-terminal --working-directory=WORK_DIR -x bash -c "COMMAND; bash"

As of January 2020, the -e option in gnome-terminal still runs properly but throws out the following warning:

For -e:

# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.

# Use “-- ” to terminate the options and put the command line to execute after it.

Based on that information above, I confirmed that you can run the following two commands without receiving any warning messages:

$ gnome-terminal -- "./scripttobash"
$ gnome-terminal -- "./genericscripttobash \"echo foo\" \"echo bar\""

I hope this helps anyone else presently having this issue :)

I really like the bash --rcfile method

I just source ~/.bashrc then add the commands I want to the new startrc.sh

now my automated start.sh work environment is complete... for now

Related