LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2007, 03:58 PM   #1
fultron
LQ Newbie
 
Registered: Apr 2005
Posts: 27

Rep: Reputation: 15
Shell Scripts and Networking to Automate macchanger


My school uses MAC filtering, which can become a real pain quite often -- like, for instance, when I switch out wireless cards. I used to have to go into admin controls, network controls, deactivate the card, then run macchanger and reactivate the card. I figured I would share this shell script, as it took me the better part of a day and a half to figure out (JUST found the ifdown command! Before I was editing config files a such) It's relatively simple, and I've seen questions related to this before.

clear
ifdown ath0
macchanger -m xx:xx:xx:xx:xx:xx ath0
ifup ath0
clear
echo "Done. MAC Address Changed."

Last edited by fultron; 02-15-2007 at 04:11 PM.
 
Old 02-16-2007, 09:02 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
Thanks for sharing. I'm sure peopel appreciate it.
Returning the gesture, let's clean up and ameliorate the script a bit:

Code:
#!/bin/sh --
# Set default GNU/Linux shell and don't use CLI args.
# Do some command checking and bail out if command not found.
inPath() { for i in ${PATH//:/ }; do [ -x "$i/$1" ] && return 0; done; }
for x in ifdown ifup macchanger; do inPath "$x" || exit 1; done
ifdown ath0 && echo -n "MAC change: " &&
macchanger -m xx:xx:xx:xx:xx:xx ath0; case "$?" in
0) echo OK; ifup ath0;; *) echo FAILED;; esac
exit 0
HTH
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 10:54 AM
Shell scripts shmuel_orgad Programming 4 05-21-2006 06:33 AM
Macchanger ???? RaT_HaCk Linux - Software 3 05-06-2005 02:28 PM
automate running scripts windyang12 Linux - Software 3 10-17-2003 12:29 PM
Shell Scripts benwy Linux - Software 1 06-09-2003 03:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration