Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wrote my own shell script, and I made it executable with "chmod +x" command. But when I click to shell file and want to run it in terminal, it suddenly opens and then closes in a second. What is the problem?

share|improve this question
2  
When scrpits have errors they exit. So unless you list the contents of the script its a guessing game –  Meer Borg Apr 23 '13 at 12:18
    
no, script hasn't any error. I just want to simply run it in Terminal with clicking to the current file. –  Ziyaddin Sadigov Apr 23 '13 at 13:07
    
Also, it's not true that scripts always exit when they have errors. Scripts such as rc.local, which are run with sh -e, will do (essentially) this. But most scripts don't run that way. Of course many scripts are deliberately written to exit under a variety of specific error conditions, but the author of the script would know about this if they had deliberately written their script that way. –  Eliah Kagan Oct 9 at 23:03

2 Answers 2

up vote 5 down vote accepted

It also closes automatically once it has run your command.
Add /bin/bash at the end of your script to keep the terminal open.

You can also add a && sleep 10 to keep the terminal open 10 seconds and see what's going on.
Best,

share|improve this answer
    
or add the sleep 10 to the exit point (end?) of the script. –  Elder Geek Oct 10 at 2:43

Try commenting out all your "exit" commands (if any) in your script by placing # in front of them and give it a go. Perhaps you are executing "exit" in your shell that closes the terminal session.

share|improve this answer
1  
Welcome to askubuntu! Your answer while possible may be a bit late as the OP already accepted the other answer. Your help is of course appreciated, however you might be better served by focusing your efforts on these: askubuntu.com/unanswered –  Elder Geek Oct 10 at 2:46

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.