Created
May 11, 2013 16:14
-
-
Save sayz/5560414 to your computer and use it in GitHub Desktop.
change mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| macs=$(cat "$MAC_FILE") | |
| if [ "$#" -lt 1 ] | |
| then | |
| # No arguments. List available macs | |
| echo "$macs" | |
| else | |
| IFS=$'\n' | |
| for m in $macs | |
| do | |
| name=$(echo "$m" | cut -d ' ' -f 1) | |
| mac=$(echo "$m" | cut -d ' ' -f 2) | |
| if [ "$name" = "$1" ] | |
| then | |
| sudo ifconfig eth0 down | |
| sudo ifconfig eth0 hw ether "$mac" | |
| sudo ifconfig eth0 up | |
| break | |
| fi | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment