3

I preface this by saying I am pretty much a complete noob when it comes to script writing.

Anyway, I am looking to create a script that opens a terminal in the GUI environment of Ubuntu, and when it does, shows the output of the other commands running in the script.

The reason for this is I am looking to take the script, throw it into the directory that runs scripts on log in and have it opening a terminal, run my normal update scripts and then keep the terminal open to allow me to continue after.

My reason is basically to just get more experience, and I figured to automate something I do every time I login.

  • It's not entirely clear what you want to do: if the goal is to run a single script, you can use a single command to bump up gnome-terminal and execute the script for you, there's no need to put gnome-terminal inside the script itself as it adds unnecessary complexity; do you want to run a single script or multiple scripts? Nonetheless is your goal to run it / them at startup or do you want to create a script that triggers the execution of the script / multiple scripts when explicitly executed? – kos Oct 12 '15 at 19:20
  • I want to run 1 script. Basically I want on login to have terminal automatically open, and then have apt-get update/upgrade/dist-upgrade run, showing the output in that screen. That's all. – chargerkirito Oct 13 '15 at 16:34
  • Ok, I've undeleted and updated my previously deleted answer, it should do what you want. – kos Oct 13 '15 at 16:42
3

I want to run 1 script. Basically I want on login to have terminal automatically open, and then have apt-get update/upgrade/dist-upgrade run, showing the output in that screen. That's all.

Make sure your script is executable and add this command to Startup Applications:

gnome-terminal -e 'bash -c "sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade; exec bash"'

This will open gnome-terminal, which will start a non-interactive bash shell (which will run sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade) and will later replace the current shell with an interactive bash shell.

If you have sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade already in a script, it would probably be more pratical to set Startup Applications to launch the script and maintain the script instead of the command in Startup Applications:

gnome-terminal -e 'bash -c "/path/to/script.sh; exec bash"'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.