LinuxÒÁµéÔ°ÂÛ̳'s Archiver

badgtg ·¢±íÓÚ 2007-10-7 16:33

Âé·³¸÷룬°ï濴һϡ£

Ïë´´½¨Ò»¸ö¼òµ¥µÄ²Ëµ¥£º
#!/bin/bash
#menu
USERNAME=`whoami`
HOSTNAME=`hostname -s`
DATE=`date +%d/%m/%Y`
while :
do
  tput clear
#here documents starts here
cat <<cs
----------------------------------------------------------
User:$USERNAME          Host:$HOSTNAME          Date:$DATE
----------------------------------------------------------
                1 : List files in current directory
                2 : Use the vi editor
                3 : See who is on the system
                H : Help screen
                Q : Exit Menu
-----------------------------------------------------------
cs
#here document finished
echo -e -n "\tYour choice[1,2,3,H,Q]:"
read CHOICE
  case $CHOICE in
   1) ls ;;
   2) vi ;;
   3) who ;;
h|H) cat <<cs
      This is the help screen,nothing here yet to help you!
cs ;;
q|Q) exit 0 ;;
   *) echo -e "\t\007unkown user response" ;;
  esac
echo -e -n "\tHit the return key to continue"
done
µ«ÔËÐÐʱ»á±¨´í£º
/root/bin/menu: line 36: syntax error: unexpected end of file
°ï濴һϣ¬ÎÊÌâ³öÔÚÄÄÀлÁË£¡

badgtg ·¢±íÓÚ 2007-10-7 16:36

ÄÇÈý¸ö±íÇé·ûºÅÊÇ     £º$

li-jiahuan ·¢±íÓÚ 2007-10-7 17:53

[code]
#!/bin/bash
#menu
USERNAME=`whoami`
HOSTNAME=`hostname -s`
DATE=`date +%d/%m/%Y`
while :
do
  tput clear
#here documents starts here
cat <<cs
----------------------------------------------------------
User $USERNAME          Host $HOSTNAME          Date $DATE
----------------------------------------------------------
                1 : List files in current directory
                2 : Use the vi editor
                3 : See who is on the system
                H : Help screen
                Q : Exit Menu
-----------------------------------------------------------
cs
#here document finished
echo -e -n "\tYour choice[1,2,3,H,Q]:"
read CHOICE
case $CHOICE in
   1) ls ;;
   2) vi ;;
   3) who ;;
   h|H) cat <<cs
      This is the help screen,nothing here yet to help you!
cs
   ;;
   q|Q) exit 0 ;;
   *) echo -e "\t\007unkown user response" ;;
  esac

echo -e -n "\tHit the return key to continue"
done
[/code]

li-jiahuan ·¢±íÓÚ 2007-10-7 17:56

Â¥Ö÷¿ÉÒԲο¼Ò»ÏÂselect²Ëµ¥

[code]
#! /bin/bash

PS3="SELECT A PROGRAM TO EXECUTE
: "
select program in 'ls -F' pwd date exit
do
        $program
#       break
done
[/code]

040410615 ·¢±íÓÚ 2007-10-7 22:28

#!/bin/bash
#menu
USERNAME=`whoami`
HOSTNAME=`hostname -s`
DATE=`date +%d/%m/%Y`
while :
do
   #clear
#here documents starts here
cat <<cs
----------------------------------------------------------
User$USERNAME          Host$HOSTNAME          Date$DATE
----------------------------------------------------------
                1 : List files in current directory
                2 : Use the vi editor
                3 : See who is on the system
                H : Help screen
                Q : Exit Menu
-----------------------------------------------------------
cs
#here document finished
echo -e -n "\tYour choice[1,2,3,H,Q]:"
read CHOICE
  case $CHOICE in
   1) ls  
          continue;;
   2) vi
         continue;;
   3) who
         continue;;
h|H) echo " This is the help screen,nothing here yet to help you!"
         continue;;
q|Q) exit 0
         ;;
   *) echo -e "\t\007unkown user response" break;;
  esac
echo -e -n "\tHit the return key to continue"
done
ÊÇwhileÑ­»·µÄÎÊÌâ  ¼ÓÉÏcontinue¾ÍÁË  
µ«×îºÃ±ð¼Óclear ·ñÔòÔÚÏÔʾ֮ǰ¾ÍÍ˳öÁË

badgtg ·¢±íÓÚ 2007-10-7 23:29

ºÇºÇ£¬Ð»ÁË£¡

dearvoid ·¢±íÓÚ 2007-10-8 09:18

ºÃÏñÓÖ¿´¼ûÁ½¸öÐÂÃæ¿×, »¶Ó­µ½ shell °æÀ´×ö¿Í :)

To Â¥Ö÷: [color=red]ÒÔºó·¢ÌùÇëÍ»³öÖ÷Ìâ[/color]

TUDOU01 ·¢±íÓÚ 2007-10-10 20:16

ÖµµÃѧϰ£¡Ñ§Ï°£¡Ñ§Ï°£¡

Ò³: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.