一般脚本里如果涉及权限问题可以在执行脚本的时候使用"sudo ./xxx.sh",如果将sudo写在脚本里面貌似不能执行,我以前写的就有类似问题发生。
2011/5/4 震 <foreve...@gmail.com> > 我初学shell,想编一个脚本,作用是根据选择序号,同时改mac和ip(临时性地修改一下即可)。脚本如下: > > #!/bin/bash > echo > echo "Type ID below to change your MAC now , 0 to exit ." > echo > echo "1 00:26:82:D8:37:0A" "2 C4:17:FE:E0:13:FD" > echo "3 00:1C:BF:96:47:37" "4 0C:60:76:13:16:7E" > echo > read m > sudo ifconfig wlan0 down > #select in "0" "1" "2" "3" "4" > #do > case $m in > 0) > sudo ifconfig wlan0 up > exit;; > 1) > sudo ifconfig wlan0 hw ether 00:26:82:D8:37:0A;; > 2) > sudo ifconfig wlan0 hw ether 00:1C:BF:96:47:37;; > 3) > sudo ifconfig wlan0 hw ether C4:17:FE:E0:13:FD;; > 4) > sudo ifconfig wlan0 hw ether 0C:60:76:13:16:7E;; > esac > > sudo ifconfig wlan0 up > sudo /etc/init.d/networking restart > > exit > > 貌似我编的不太对,每次运行以后,网就断开了。求修正,谢谢! > 另外,不知道临时性更改ip怎么做?再次谢谢! > -------------- 下一部分 -------------- > 一个HTML附件被移除... > URL: < > https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110504/fba28c39/attachment.html > > > -- > ubuntu-zh mailing list > ubuntu-zh@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh > -------------- 下一部分 -------------- 一个HTML附件被移除... URL: <https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110504/ced3a6db/attachment.html> -- ubuntu-zh mailing list ubuntu-zh@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh