Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章
谢谢各位,我已经做好了,附上代码~

#!/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: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh


Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章
不知道呀为什么要restart,我是在网上搜“ubuntu改mac地址”搜出来的四句命令,手动输入一切正常。
在 2011-5-4 下午11:30,"Earthson" 写道:
> 为什么要restart网络呢?
>
> 2011/5/4 David Lee 
>
>> 参考RLP的,应该是ifconfig
>>
>> 再者你连的是wlan0,是无线wifi网络,一般情况下都是自动分配ip地址的,设置为auto就行。
>>
>> 2011/5/4 Lei Wang 
>>
>> > 一般脚本里如果涉及权限问题可以在执行脚本的时候使用"sudo
>> ./xxx.sh",如果将sudo写在脚本里面貌似不能执行,我以前写的就有类似问题发生。
>> >
>> > 2011/5/4 震 
>> >
>> > > 我初学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
>> >
>>
>>
>>
>> --
>> Regards, David
>> -- 下一部分 --
>> 一个HTML附件被移除...
>> URL: <
>>
https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110504/7fe041a0/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/5f25568a/attachment.html
>
> --
> ubuntu-zh mailing list
> ubuntu-zh@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
-- 下一部分 --
一个HTML附件被移除...
URL: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh


Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章
我们那个局域网,用的是ip加mac配对了认证的方式,一个人一个固定的ip。我要做的就是看谁不在,就伪装成各个人然后能上网。
在 2011-5-4 下午11:22,"David Lee" 写道:
>
> 参考RLP的,应该是ifconfig
>
> 再者你连的是wlan0,是无线wifi网络,一般情况下都是自动分配ip地址的,设置为auto就行。
>
> 2011/5/4 Lei Wang 
>
> > 一般脚本里如果涉及权限问题可以在执行脚本的时候使用"sudo
./xxx.sh",如果将sudo写在脚本里面貌似不能执行,我以前写的就有类似问题发生。
> >
> > 2011/5/4 震 
> >
> > > 我初学shell,想编一个脚本,作用是根据选择序号,同时改mac和ip(临时性地修改一下即可)。脚本如下:
> > >
> > > #!/bin/bash
> > > echo
> > > echo "Type ID below to change your MAC now , 0 to exit ."
> > > echo
> > > echo "100:26:82:D8:37:0A""2C4:17:FE:E0:13:FD"
> > > echo "300:1C:BF:96:47:37""40C: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
> >
>
>
>
> --
> Regards, David
> -- 下一部分 --
> 一个HTML附件被移除...
> URL: <
https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110504/7fe041a0/attachment.html
>
> --
> ubuntu-zh mailing list
> ubuntu-zh@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
-- 下一部分 --
一个HTML附件被移除...
URL: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh


Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章 Jiahua Huang
sudo 没问题。

把末尾的 restart 去掉。

2011/5/4 Lei Wang 

> 一般脚本里如果涉及权限问题可以在执行脚本的时候使用"sudo ./xxx.sh",如果将sudo写在脚本里面貌似不能执行,我以前写的就有类似问题发生。
>
> 2011/5/4 震 
>
> > 我初学shell,想编一个脚本,作用是根据选择序号,同时改mac和ip(临时性地修改一下即可)。脚本如下:
> >
> > #!/bin/bash
> > echo
> > echo "Type ID below to change your MAC now , 0 to exit ."
> > echo
> > echo "100:26:82:D8:37:0A""2C4:17:FE:E0:13:FD"
> > echo "300:1C:BF:96:47:37""40C: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怎么做?再次谢谢!
-- next part --
An HTML attachment was scrubbed...
URL: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh


Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章 Earthson
为什么要restart网络呢?

2011/5/4 David Lee 

> 参考RLP的,应该是ifconfig
>
> 再者你连的是wlan0,是无线wifi网络,一般情况下都是自动分配ip地址的,设置为auto就行。
>
> 2011/5/4 Lei Wang 
>
> > 一般脚本里如果涉及权限问题可以在执行脚本的时候使用"sudo
> ./xxx.sh",如果将sudo写在脚本里面貌似不能执行,我以前写的就有类似问题发生。
> >
> > 2011/5/4 震 
> >
> > > 我初学shell,想编一个脚本,作用是根据选择序号,同时改mac和ip(临时性地修改一下即可)。脚本如下:
> > >
> > > #!/bin/bash
> > > echo
> > > echo "Type ID below to change your MAC now , 0 to exit ."
> > > echo
> > > echo "100:26:82:D8:37:0A""2C4:17:FE:E0:13:FD"
> > > echo "300:1C:BF:96:47:37""40C: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
> >
>
>
>
> --
> Regards, David
> -- 下一部分 --
> 一个HTML附件被移除...
> URL: <
> https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110504/7fe041a0/attachment.html
> >
> --
> ubuntu-zh mailing list
> ubuntu-zh@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
>



-- 

这个世界不会因为没有你而失去什么
但是,却有可能因为你的存在而发生一些改变。。
-- 下一部分 --
一个HTML附件被移除...
URL: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh


Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章 David Lee
参考RLP的,应该是ifconfig

再者你连的是wlan0,是无线wifi网络,一般情况下都是自动分配ip地址的,设置为auto就行。

2011/5/4 Lei Wang 

> 一般脚本里如果涉及权限问题可以在执行脚本的时候使用"sudo ./xxx.sh",如果将sudo写在脚本里面貌似不能执行,我以前写的就有类似问题发生。
>
> 2011/5/4 震 
>
> > 我初学shell,想编一个脚本,作用是根据选择序号,同时改mac和ip(临时性地修改一下即可)。脚本如下:
> >
> > #!/bin/bash
> > echo
> > echo "Type ID below to change your MAC now , 0 to exit ."
> > echo
> > echo "100:26:82:D8:37:0A""2C4:17:FE:E0:13:FD"
> > echo "300:1C:BF:96:47:37""40C: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
>



-- 
Regards, David
-- 下一部分 --
一个HTML附件被移除...
URL: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh


Re: [Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章 Lei Wang
一般脚本里如果涉及权限问题可以在执行脚本的时候使用"sudo ./xxx.sh",如果将sudo写在脚本里面貌似不能执行,我以前写的就有类似问题发生。

2011/5/4 震 

> 我初学shell,想编一个脚本,作用是根据选择序号,同时改mac和ip(临时性地修改一下即可)。脚本如下:
>
> #!/bin/bash
> echo
> echo "Type ID below to change your MAC now , 0 to exit ."
> echo
> echo "100:26:82:D8:37:0A""2C4:17:FE:E0:13:FD"
> echo "300:1C:BF:96:47:37""40C: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: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh


[Ubuntu-zh] 刚自学shell脚本,编了一个貌似不对,求助

2011-05-04 文章
我初学shell,想编一个脚本,作用是根据选择序号,同时改mac和ip(临时性地修改一下即可)。脚本如下:

#!/bin/bash
echo
echo "Type ID below to change your MAC now , 0 to exit ."
echo
echo "100:26:82:D8:37:0A""2C4:17:FE:E0:13:FD"
echo "300:1C:BF:96:47:37""40C: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: 

-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh