I'm having troubles with my internet connection and need to connect to my router with a different mac address every time. This script creates a random mac address and tries to set it, when the two mac-addresses displayed by this script are the same, it was set successfully.
macAddress=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
sudo ifconfig en0 ether $macAddress
echo "new mac address:"
echo $macAddress
sudo ifconfig en0 ether