LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 910|回复: 10

[请教]如何写这样的一个交互脚本?

[复制链接]
此用户还没注册 该用户已被删除
发表于 2004-6-1 14:14:41 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2004-6-1 14:29:08 | 显示全部楼层
呵呵,用shell,你会发现,dos就是垃圾啦  

  1. read input?"please enter :"
  2. case $input in
  3. 1)     command1;;
  4. 2)     command2;;
  5. *)     echo "wrong input";;
  6. esac
复制代码
发表于 2004-6-1 18:06:35 | 显示全部楼层
用 select 也可啦, 而且它还能显示一个菜单
此用户还没注册 该用户已被删除
 楼主| 发表于 2004-6-1 19:04:24 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
此用户还没注册 该用户已被删除
 楼主| 发表于 2004-6-1 19:11:58 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2004-6-1 19:37:21 | 显示全部楼层
懒惰 ! 自己 help read 看看 !
此用户还没注册 该用户已被删除
 楼主| 发表于 2004-6-1 23:31:42 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2004-6-1 23:37:05 | 显示全部楼层
/home/lee#cat input
#!/bin/bash
echo -n "please enter :"
read input
case $input in
1)     date;;
2)     pwd;;
*)     echo "wrong input";;
esac
/home/lee#bash input
please enter :1
二  6月  1 23:38:56 CST 2004
/home/lee#bash input
please enter :
wrong input
/home/lee#bash input
please enter :2
/home/lee
/home/lee#bash input
please enter :
wrong input
/home/lee#bash input
please enter :5
wrong input
/home/lee#
ps:建议兄弟看看本论坛的置顶贴,
http://www.linuxsir.cn/bbs/showthread.php?threadid=28945
此用户还没注册 该用户已被删除
 楼主| 发表于 2004-6-2 13:35:42 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
此用户还没注册 该用户已被删除
 楼主| 发表于 2004-6-2 14:04:01 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表