0

I'm trying to get a script to run at startup using Startup Applications. I want it to run in a terminal window (and stay open). It is a monitoring script.

I have been able to get the terminal window to open on startup with no command using "gnome-terminal" but I can't get the --command syntax right and I can't see errors given the window doesn't open when it is wrong.

gnome-terminal --command /path/to/script.sh

Can someone correct what I'm doing wrong?

Thanks

2 Answers 2

2

Your syntax as such is right. Gnome developers indicate they will remove it, and now advocate using -- to end all options so everything after that is evaluated as a command. That syntax would be gnome-terminal -- /path/to/script.sh. They, however, forgot that that new syntax prevents you from opening several tabs or windows at once, e.g. to automatically connect to different ssh servers on startup.

Why you do not see a terminal would suggest that your script releases the terminal prompt as soon as it is started. That could happen if the script launches processes in the background. If you want to keep the terminal open, add a "bash" statement or something else like read -n 1 -s -r -p "Press any key to continue". You can add that in the script, or as a second command as in gnome-terminal -- /path/to/script.sh ; bash.

Another method to achieve that from a startup launcher is not exposed in the user interface: you need to edit the .desktop launcher manually. It is in your .config/autostart folder. With that method, you only enter the path to the executable script as the command, but indicate that it should be run in a terminal:

...
Exec=/path/to/script.sh
...
Terminal=true
...

With both of the approaches, that terminal will close once the script is terminated.

0

Just run gnome-terminal -- /path/to/script.sh inside an other gnome-terminal to find whats happening. The --command option is deprecated. Also make sure your script file has the right permissions chmod u+x YourScriptFileName.sh and that your script has a shebang #!/bin/bash.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .