max pleaner max pleaner - 1 year ago 57
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.

Answer Source

You can check the exit status.

./ || read

This will wait for a keypress if the command failed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download