LinuxSir.cn,穿越时空的Linuxsir!

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

read在自启动脚本里无效?

[复制链接]
发表于 2009-2-21 15:37:02 | 显示全部楼层 |阅读模式
因为需要切换网络环境,自己写了一个脚本:
  1. #!/bin/sh
  2. #
  3. # netc initscript
  4. #
  5. ### BEGIN INIT INFO
  6. # Provides:          netchoose
  7. # Required-Start:    $local_fs
  8. # Required-Stop:     $local_fs
  9. # Should-Start:      $network
  10. # Should-Stop:       $network
  11. # Default-Start:     S
  12. # Default-Stop:      0 6
  13. # Short-Description: Switch the network configuration
  14. ### END INIT INFO

  15. . /lib/lsb/init-functions

  16. echo "1. lab"
  17. echo "2. dorm"

  18. read n
  19. case "$n" in
  20. 1)
  21.     cp -f /etc/network/interfaces-1 /etc/network/interfaces;;
  22. 2)
  23.     cp -f /etc/network/interfaces-2 /etc/network/interfaces;;
  24. *)
  25.     cp -f /etc/network/interfaces-1 /etc/network/interfaces;;
  26. esac

  27. exit 0
复制代码

保存为/etc/init.d/netchoose
  1. # ls -l /etc/init.d/netchoose
  2. -rwxr-xr-x 1 root root 632 2009-02-21 15:26 /etc/init.d/netchoose
  3. # ln -s /etc/init.d/netchoose /etc/rcS.d/S40netchoose
复制代码

但开机时虽然显示
  1. 1. lab
  2. 2. dorm
复制代码

却没有等待用户输入,直接执行下一个脚本S40networking去了
奇怪的是在我的Debian虚拟机里这个脚本就运行得很好
把read这行换成从文件里读入就没问题了n=( `cat /home/swicol/.config/netcv`)
但这样就太不方便了
谁能帮帮忙解释一下?
发表于 2009-2-22 13:17:39 | 显示全部楼层
tty 还没有好吧..
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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