Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a automatic build script it uses a makefile which starts different ant scripts depending on the target

I start it using xterm (I have a shortcut on the desktop) It works fine but if I want to check if the execution was successful I cant close the terminal automatically

Is there a terminal emulator which wont auto close if there was an error during execution ?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

You seem to open a terminal to run one command and close the terminal. This is a highly unusual workflow outside the Windows world. The usual workflow is to have a terminal open permanently, and run commands in it when needed. Or, when the command is a build command, work in an IDE and have it invoke the build process.

If you insist in creating a new terminal each time (a bad idea, because that will make messages from prior builds immediately unavailable), you can make the terminal wait in case of error by inserting a shell snippet that checks the return status, and waits for input if there is an error.

xterm -e sh -c 'ant mytarget || read line'

If the build process completes successfully, the terminal window will be closed immediately. If the build process fails, the terminal window will be closed after you press Enter.

share|improve this answer

So do not put exit in the end of the script and/or check return code...

share|improve this answer
    
this does not work with xterm it closes unless you set the -hold flag but you are right I can check the exit code and wait for user input if there is an error still I hope there is a terminal emulator which can do this –  sherif Feb 21 '12 at 14:17
1  
@sherif just change the command that the shortcut runs. make foobar || read will wait for an <ENTER> keypress if make fails. –  Patrick Feb 22 '12 at 2:05

I think what Jiri meants was that you should use xterm, without -hold, and change your build script to only exit if it completes successfully. If there is an error, have your build script stop and wait for a key press from the user. If your build script is a bash script, just use the read statement:

read unused_var
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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