Notices


Reply
Thread Tools
munky261's Avatar
Posts: 1,674 | Thanked: 171 times | Joined on Mar 2007 @ Anderson, IN
#1
I was wondering if it is possible to write a scipt to execute three separate commands as root..the result of which is changing the mac address of my N810. Here are the three commands:

ifconfig wlan0 down

macchanger --r wlan0

ifconfig wlan0 up


Basically what I'd like to do is to be able to click just one button to change the mac, rather than have to go through the whole process. Any suggestions would be greatly appreciated!
__________________
There is only one Return, and it's not of the King, it's of the Jedi.
 
munky261's Avatar
Posts: 1,674 | Thanked: 171 times | Joined on Mar 2007 @ Anderson, IN
#2
Anyone?...............................
__________________
There is only one Return, and it's not of the King, it's of the Jedi.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#3
Ive never used macchanger ... but if all you want to do is run those three commands, in that order, just drop them into a text file and make it executable. (putting #!/bin/sh at the top is recommended)

If you want a menu icon you can use like Personal Menu or something to create one for the command, or create your own .desktop for it..
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
munky261's Avatar
Posts: 1,674 | Thanked: 171 times | Joined on Mar 2007 @ Anderson, IN
#4
How do I make it executable? Do I need to change the extension?
__________________
There is only one Return, and it's not of the King, it's of the Jedi.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#5
Well I don't remember the normal filesystems of the N810. Something like this should work (as root):

Code:
cat >> /usr/bin/changemymac << EOF
#!/bin/sh
ifconfig wlan0 down
macchanger --r wlan0
ifconfig wlan0 up
EOF
chmod +x /usr/bin/changemymac
You now have a new command "changemymac". It would have to be run as root though, so you'd need to pass it through to sudo gainroot or "root" in a .desktop file or Personal Menu launcher ala:
Code:
echo changemymac | root
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
munky261's Avatar
Posts: 1,674 | Thanked: 171 times | Joined on Mar 2007 @ Anderson, IN
#6
So, if I make a .desktop after doing that, I would put sudo /usr/bin/changemymac for the exec and it should work?
__________________
There is only one Return, and it's not of the King, it's of the Jedi.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#7
Originally Posted by munky261 View Post
So, if I make a .desktop after doing that, I would put sudo /usr/bin/changemymac for the exec and it should work?
Theoretically yes..

I've never gotten sudo to work directly like that without making my own modifications to the sudoers file. I don't think the "user" user is able to run just any command with sudo. For the exec line I would try what I had above:

echo changemymac | sudo gainroot

or

echo changemymac | root
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#8
Another idea is if you do:

Code:
cat > /usr/bin/changemymac << EOF
#!/bin/sh
echo ifconfig wlan0 down | root
echo macchanger --r wlan0 | root
echo ifconfig wlan0 up | root
EOF
chmod +x /usr/bin/changemymac
Instead, you should just be able to run "changemymac" as user and it'll run each of those commands as root.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#9
I should probably put a warning somewhere in this thread about running random scripts as root to be sure you know what you're doing and etc. etc. etc....

If your N810 kills your kitten after running my commands I take no responsibility... blah.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
munky261's Avatar
Posts: 1,674 | Thanked: 171 times | Joined on Mar 2007 @ Anderson, IN
#10
Awesome, the first way worked...just made a . desktop with an exec of exec= sudo /usr/bin/changemymac and it worked great. Only one issue, after i disconnect my connection and reconnect for the new mac to take effect, my sip account wont connect. when I do it the manual way in xterm it connects fine...any ideas why it wont connect?
__________________
There is only one Return, and it's not of the King, it's of the Jedi.
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:16.