Keep Terminal windows from closing automatically
This tip is based on the tip Title your Terminal.
When you launch a console application in a Terminal window, the window will generally be closed after execution, which means you can’t read the results (note that this is not true when you simply type the name of a command into a Terminal window, but when you launch a new Terminal and a command all at once). To get around the situation, try this:
1) Launch the terminal with the -t flag, passing it a title and a script file. For example:
Terminal -t "Compiling..." /bin/sh -c /boot/home/scriptfile
2) Include in the scriptfile the following commands (for example):
# call the GNU C++ compiler gcc # send a message to User after execution printf "return to continue " #read the keystroke and close the Terminal application read -e response
The final read
command will cause the window to stay open until you press a key. This lets you launch the GNU C++ compiler in a new Terminal window and read the compiler output without closing the Terminal window automatically.