Sunday, April 28, 2024
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 31771  / 1 Year ago, fri, may 19, 2023, 9:58:54

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?


More From » command-line

 Answers
3

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.



Alternatively, add another line containing read at the end of the script to keep the terminal open until you press Enter.


[#31645] Saturday, May 20, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ciousuntru

Total Points: 352
Total Questions: 124
Total Answers: 95

Location: Grenada
Member since Tue, Oct 12, 2021
3 Years ago
;