Applescript help

Discussion in 'Mac Basics and Help' started by El Aldio, Nov 19, 2013.

  1. El Aldio macrumors newbie

    El Aldio

    Joined:
    Oct 23, 2011
    #1
    Hi MacRumors, I’ve got a problem with my Mac that could be probably solved with new logicboard but no warranty = no luck.
    Problem is that MAC address of my ethernet keeps changing to something like 00:01:xx:xx:xx:xx. This causes two problems for me: school network has problem assigning IP address since it’s different than the right (registered) one. Second problem is that apps from MAS want to re-authorize every time saying they were bought from different computer (but if I login with my Apple ID, it works). Both problems are solved if I change ethernet address before I either connect to the network or launch one of those apps.
    So I came up with this AppleScript, made it run after startup and deleted app (Window Magnet) that had problem with wrong address from Login items:
    Code:
    set ethad to do shell script "ifconfig en0 |grep ether"
    if ethad is " ether c8:bd:xx:xx:xx:xx " then
    tell application "Window Magnet" to activate
    else
    do shell script "sudo ifconfig en0 ether c8:bd:xx:xx:xx:xx
    echo password"
    tell application "Window Magnet" to activate
    end if
    What I want it to do:
    • ask current ethernet mac address
    • if it’s right, launch Window Magnet
    • if it isn’t then run command to change MAC address to the original one
    • enter password (echo command: didn’t find better way)
    • activate Window Magnet
    It worked for about a week but now it simply says there’s an error number 10810.
    Do you have any ideas how to fix it or where could be a problem? Or should I rewrite it (how?)?
     
  2. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #2
    Code:
    set ethad to do shell script "ifconfig en0 |grep ether"
    if ethad is " ether c8:bd:xx:xx:xx:xx " then
    tell application "Window Magnet" to activate
    else
    do shell script "sudo ifconfig en0 ether c8:bd:xx:xx:xx:xx" with administrator privileges
    tell application "Window Magnet" to activate
    end if
    Sorry I can't test the syntax at the office but the general idea is to add "with adminstrator" to any shell script that needs your password to do something and it will prompt the user when it gets to that line.
     
  3. El Aldio thread starter macrumors newbie

    El Aldio

    Joined:
    Oct 23, 2011
    #3
    Thanks man! It seems to be working for now. I will see if it stays this way after a few reboots.
     

Share This Page