PDA

View Full Version : [SOLVED] Bash Script Problem



SKhan
May 23rd, 2010, 09:27 PM
when i execute a hello world bash file, terminal appears and disappears, nothing else happens.
what to do now in order to see the resulted "hello world" text?

sharath.puranik
May 23rd, 2010, 09:28 PM
Show us the code you are using for this script.

da burger
May 23rd, 2010, 09:32 PM
If a terminal is opened by a launcher it closes again when the program finishes. Try running the command from with a terminal.

tada
May 23rd, 2010, 10:42 PM
Add the following to the end of your script:

read x


This will force the code to wait for you to hit enter - so if this is being shown in a popup terminal, that terminal will have to wait for you.

X is nothing important - its the 'read' thats doing the work

lovinglinux
May 23rd, 2010, 10:44 PM
Open the terminal, go to "Edit >> Profile Preferences >> Title and Command >> "When command exits" and set it to "Hold the terminal open".

You could also add a command to the end of script to keep it open, but I'm trying to figure out which command would do that myself.

Edit: the command is on previous post :)

bumanie
May 23rd, 2010, 11:28 PM
Here's a good (http://gd.tuwien.ac.at/linuxcommand.org/writing_shell_scripts.php) (and easy to follow) tutorial on bash script writing. Hope it helps.

SKhan
May 24th, 2010, 04:55 PM
Show us the code you are using for this script.

#! /bin/bash
echo "Hello World!"

SKhan
May 24th, 2010, 04:56 PM
thanks guys problem solved.