max pleaner max pleaner - 5 months ago 24
Linux Question

Rescue errors in terminal launched from script

I am using Ubuntu and made a short script on my Desktop. Double clicking it opens a terminal and starts my server.

This is all working fine except there's one problem. If there's an error raised in my server, the launched terminal immediately closes.

I want to keep the terminal open and show the error.

Here's my script:


gnome-terminal -e '/bin/bash -c "cd ~/Desktop/browser_tester/; ./" '

I'm using the advice from this AskUbuntu answer to construct that command. I'm asking for a way to rescue errors inside the subprocess so that the
displays those errors and doesn't just exit.


You can check the exit status.

./ || read

This will wait for a keypress if the command failed.