Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: How to make shell script pause?

  1. #1
    Join Date
    Jul 2006
    Beans
    Hidden!

    How to make shell script pause?

    Whenever I run a bash script in the terminal (double click on it, "Run in Terminal") it will open up a terminal window, complete the script and exit RIGHT after it finishes giving me no time to review the output. I would like the script to leave the terminal window open after it finishes and allow further commands if possible. How would I do this? I know the sleep command can pause the script for a designated ammount of time and then close the terminal but this is an imperfect solution.
    Last edited by fatsheep; October 1st, 2006 at 10:39 PM.

  2. #2
    Join Date
    Sep 2006
    Beans
    Hidden!

    Re: How to make shell script pause?

    fatsheep,

    I assume you are using Gnome Terminal. In this case, open up a new terminal window. Go to the "Edit" menu and click "Current Profile". Click on the "Title and Command" tab. In there, there is a setting called "When command exits". Change it to "hold the terminal open".

  3. #3
    Join Date
    Jul 2006
    Beans
    Hidden!

    Re: How to make shell script pause?

    Quote Originally Posted by po0f View Post
    fatsheep,

    I assume you are using Gnome Terminal. In this case, open up a new terminal window. Go to the "Edit" menu and click "Current Profile". Click on the "Title and Command" tab. In there, there is a setting called "When command exits". Change it to "hold the terminal open".
    Cool. Thanks a bunch. However, is there any way to do this inside a script itself?

  4. #4
    Join Date
    Sep 2006
    Beans
    Hidden!

    Re: How to make shell script pause?

    fatsheep,

    I think you would manually have to open up a terminal and run the script if you wanted to do it that way. AFAIK, there is no way to do this from a script. When the script exits, whatever program called it (Nautilus in this case, I'm guessing), gets the exit signal and closes the terminal. That's why Gnome Terminal has that setting.

  5. #5
    Join Date
    Sep 2006
    Beans
    2,914

    Re: How to make shell script pause?

    Quote Originally Posted by fatsheep View Post
    Whenever I run a bash script in the terminal (double click on it, "Run in Terminal") it will open up a terminal window, complete the script and exit RIGHT after it finishes giving me no time to review the output. I would like the script to leave the terminal window open after it finishes and allow further commands if possible. How would I do this? I know the sleep command can pause the script for a designated ammount of time and then close the terminal but this is an imperfect solution.
    use the read command ?

  6. #6
    Join Date
    Jul 2006
    Beans
    Hidden!

    Re: How to make shell script pause?

    Quote Originally Posted by ghostdog74 View Post
    use the read command ?
    Works like a charm. Thanks a bunch!

  7. #7
    Join Date
    Aug 2006
    Location
    Belgium
    Beans
    Hidden!
    Distro
    Xubuntu 8.04 Hardy Heron

    Re: How to make shell script pause?

    And if you simply want a pause, use sleep

    Code:
    sleep 10
    will sleep 10 seconds (10 can be any number ) (a long as it's positive)

  8. #8
    Join Date
    Mar 2006
    Beans
    85

    Re: How to make shell script pause?

    If you don't want to change the code of the script, you can simply hit ctrl+z on the keyboard to suspend any process running in foreground and run fg to resume it in foreground (or bg to resume it in background).

  9. #9
    Join Date
    Apr 2007
    Beans
    7

    Re: How to make shell script pause?

    Quote Originally Posted by fatsheep View Post
    Works like a charm. Thanks a bunch!
    For some weird reason the read command doesn't keep the terminal open for me. But if I run the script through a terminal manualy then it gives the desired effect. I am using something like this:

    Code:
    #/bin/bash
    
    './LUA Binaries/LUA Binaries for Linux/lua5.1' './source/AskWise.lua'
    read
    Should it work?

  10. #10
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,240
    Distro
    Kubuntu

    Re: How to make shell script pause?

    If you merely want access to the shell after your script is complete, try this:

    Code:
    xterm -e 'bash myscript.bash && bash'
    With this concept you would *not* require the 'read' statement in your script. Btw, for some reason I could not get the same results when I substituted gnome-terminal for xterm. Maybe a gnome guru can explain this.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •