可以试试将mac地址也做成变量保存,使脚本中只有一个出口,也只有一个down和up对,让人赏心悦目。 而且可以是down延迟,在输入错误时可以掠过down。 小建议,可以试着玩玩。
-----邮件原件----- 发件人: [email protected] [mailto:[email protected]] 代表 震 发送时间: 2011年5月5日星期四 13:34 收件人: ubuntu-zh mailing lists 主题: Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助 谢谢各位,我已经做好了,附上代码~ #!/bin/bash echo echo "They are the known hosts :" echo echo "29 攀 0C:60:76:13:16:7E" echo "30 欣 00:26:82:2B:CF:D7" echo "36 薇 00:1F:3C:1A:E9:02" echo "41 亮 00:26:82:D8:37:0A" echo "75 飞 00:1C:BF:96:47:37" echo "83 倩 C4:17:FE:E0:13:FD" echo echo "Type ID above to change your MAC now , 0 to change nothing ." read m sudo ifconfig wlan0 down case $m in 29) sudo ifconfig wlan0 hw ether 0C:60:76:13:16:7E;; 30) sudo ifconfig wlan0 hw ether 00:26:82:2B:CF:D7;; 36) sudo ifconfig wlan0 hw ether 00:1F:3C:1A:E9:02;; 41) sudo ifconfig wlan0 hw ether 00:26:82:D8:37:0A;; 75) sudo ifconfig wlan0 hw ether 00:1C:BF:96:47:37;; 83) sudo ifconfig wlan0 hw ether C4:17:FE:E0:13:FD;; *) echo "unknown host , nothing changed ." sudo ifconfig wlan0 up ifconfig wlan0 exit;; esac sudo ifconfig wlan0 up sudo /etc/init.d/networking restart ifconfig wlan0 192.168.1.$m ifconfig wlan0 exit 再次谢谢大家的帮助! -------------- 下一部分 -------------- 一个HTML附件被移除... URL: <https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110505/2f3fde21/attachment.html> -- ubuntu-zh mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh -- ubuntu-zh mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
