LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-14-2004, 07:22 PM   #1
quack322
LQ Newbie
 
Registered: Jun 2004
Distribution: Redhat 9
Posts: 11

Rep: Reputation: 0
Simple choice script


I need the basics of a simple shell script that gives the user a choice. For example

1) Restart
2) Shutdown
3) Logoff
Enter choice:

I do not want to use any "dialog" for this script

--Thanks
 
Old 08-14-2004, 08:37 PM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
http://tille.soti.org/training/bash/
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/
http://ldp.nllgg.nl/LDP/abs/html/

learn $BASH
 
Old 08-14-2004, 09:03 PM   #3
futhark
Member
 
Registered: Nov 2003
Location: Montréal (Can)
Distribution: FC4
Posts: 110

Rep: Reputation: 15
Ask google for "advanced bash". This is the best doc I know.
I also look often at startup scripts in /etc/init.d when I don't remember some constructs.

Code:
#!/bin/sh

cat << _EOF_
1) Restart
2) Shutdown
3) Logoff
_EOF_

while [ 1 ] ; do
  echo -n "Enter choice and hit enter: "
  read CHOICE
  case "$CHOICE" in
    1 )
      echo "execute restart"
      exit
      ;;
    2 )
      echo "execute shutdown"
      exit
      ;;
    3 )
      echo "execute logoff"
      exit
      ;;
  esac
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
mandrake10.1 after upgrade kde3.3&gnome2.8 simple loginwith no choice & no desktop msalimane Mandriva 3 11-22-2004 08:27 PM
Simple script Savahn Programming 2 07-14-2004 05:23 PM
simple script hso_sof Linux - Software 2 08-25-2003 12:09 PM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration