Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Dummy shell script question
Results 1 to 8 of 8

Thread: Dummy shell script question

  1. #1

    Dummy shell script question

    i just made my first attempt to write a shell script on RH 7.2.
    I want to provide admins in other cities (who don't know much about linux) with manu-based access to Linux NTP server running on our site. The problem with the script is that I need the result of commands to be displayed on the screen with option to hit enter and return to main manu (which I don't know how to do)
    while true
    do
    /usr/bin/clear
    echo " NTP MENU "
    echo "--------------------------------------------"
    echo " Select one of the following:"
    echo " 1. NTP communication status "
    echo " 2. Check if NTP daemon is running"
    echo " 3. Restart NTP daemon"
    echo " 4. Exit"
    echo " Press 1,2,3, or 4 and Enter"

    read Keypress

    case "$Keypress" in
    1 ) /usr/sbin/ntpq -p ;;
    2 ) /bin/ps -ef | grep ntp ;;
    3 ) /sbin/service ntp restart ;;
    4 ) /usr/bin/clear
    /bin/echo "Bye-bye!"
    exit ;;
    esac
    done

    exit

    Can anyone help me regarding my question?
    Thanks.

  2. #2

    Re:Dummy shell script question

    I don't know of a command that will allow you to do that. If you pipe the output to more or page commands, you won't have the option to hit return to go back to the original menu. That may be enough though. If they know to hit q they will break out and return to the menu. Otherwise you can redirect the output from the commands to a temp file and use a while loop to echo a number of lines, maybe 25 or so and give the prompt to either page forward or quit. I'm sure that someone has a better idea. Good luck. If you need help, just post. I've written scripts similar to this.

  3. #3

    Re:Dummy shell script question

    What is the equivalent of 'pause' command in Linux environment?
    Thanks.

  4. #4

    Re:Dummy shell script question

    "pause" is that a DOS command? What does "pause" do? Look at page and more commands. They may be similar.

  5. #5
    Associate
    Join Date
    Dec 2002
    Posts
    13

    Re:Dummy shell script question

    Don't know about a real equivalent of "pause" in Linux.
    But maybe this is sufficient for your purpose?

    Code:
    echo "Hit ENTER to continue..."
    read


  6. #6

    Re:Dummy shell script question

    Great ! It works.
    Can you did some litlle explanation as to what 'read' does?
    thanks.

  7. #7

    Re:Dummy shell script question

    read waits for you to enter something ... you can type anything, but only enter (or maybe somekey^ will work too) will make it continue...and some internal bash variable will hold whatever you typed in before you hit enter...

  8. #8
    Associate
    Join Date
    Dec 2002
    Posts
    13

    Re:Dummy shell script question

    [quote author=trieder link=board=9;threadid=6558;start=0#61919 date=1047629172]
    [...snip...]and some internal bash variable will hold whatever you typed in before you hit enter...
    [/quote]
    But in my example the internal bash variable was omitted, because "read" was used just to wait. No need to store input.

Similar Threads

  1. Shell script coding
    By lab in forum Programming
    Replies: 0
    Last Post: 07-14-2012, 05:18 AM
  2. Shell script coding
    By lab in forum Programming
    Replies: 0
    Last Post: 07-05-2012, 01:49 PM
  3. Shell script for geoiplookup cmd
    By Hariharan in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 10-19-2010, 10:18 AM
  4. Need of shell script
    By Hariharan in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 09-16-2010, 02:34 PM
  5. Shell script for monitoring
    By Hariharan in forum Linux - Software, Applications & Programming
    Replies: 0
    Last Post: 09-16-2010, 05:54 AM

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
  •