Network settings help

Discussion in 'Mac Basics and Help' started by InfiniteLoopy, Aug 7, 2014.

  1. InfiniteLoopy macrumors 6502

    Joined:
    Dec 14, 2010
    #1
    Hello,

    I’m trying to setup something that I thought was simple but is proving not to be.
    Can anyone help?

    One Mac, multiple users, two wifi networks.

    All users connect to a wifi, except one user who connects automatically at login to the other wifi network.

    I’ve tried locations, scripts, etc. without much success.

    Thanks in advance
     
  2. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #2
    I think locations would work, but it sounds like you want a way to automatically switch to a different network location when this user logs in yes?

    http://www.controlplaneapp.com

    Take a look at the app Control Plane. What is does is look for "evidence sources" then those can trigger an action like switching the network location. So look through the evidence sources on the support list there and figure one out that you can auto launch at login that would trigger the network location switch.
     
  3. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #3
    Hi,

    Thanks. Looks like a good app.
    Can you help with setting up the actions?
    I'm trying with a rule where the wifi SSID is the name of the main wifi network. How would you setup an action?
    Would you use different locations?

    Thanks
     
  4. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #4
    Yeah... that's what I was thinking. Make two locations, one for each wifi. The have control plane switch to the one you want based on an app that launches at login for example.
     
  5. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #5
    Thanks.
    I can't get the locations to work. Both wifi networks appear in all locations. I can't seem to manage to assign one wifi to one location and one to the other.
    Any advice?
     
  6. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #6
    Hmmm... I am tinkering around here and the hang up is it remembers any joined network across both locations. Let me mess around here a bit more and I think I have an idea to do this with Applescript and. I'll get back with you.
     
  7. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #7
    Great thanks.
    If I could load an apple script on launch (for the user account that needs to connect to separate wifi access) that would change the wifi network automatically, that would be fine. I'm actually surprised Apple don't make this simpler.
    If it helps, it's two separate routers.

    Also, I wonder if I wouldn't need an applescript on logout to revert back to the other network for the other users?
     
  8. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #8
    Code:
    do shell script "networksetup -setairportnetwork en0 SSID password"
    Okay... I have an idea. I tested a bit here and it seems to work okay.

    Paste the above in Applescript editor and change the SSID and password to your real info. Then click run in Applescript editor and it switches form the existing wifi network to the one in the script.

    So just change the script to match the wifi info for the single user who needs his own wifi and save the Applescript as an application. Then put the application in his login items. This way whenever he logs in, no matter what wifi network it is on, it will switch him to this one.

    So I think that fixes him up.

    Now for the other users. Make another Applescript but change it to switch to their SSID and set it up the same way as an application that launches as a login item. Should work the same way. No matter what wifi network it is on at login it will switch over to theirs.

    You will need to set this up as a login item for each of those other users.

    Unless I have overlooked something, I think this will do what you want.

    The downside is the wifi passwords are not encrypted inside that application and if one knows how to lock inside an Applescript application package they could see the password. But it sounds like in your environment this might not be a problem.

    Now watch as soon as I post this someone will post a link to a simple application that does this for you. :)
     
  9. BrianBaughn macrumors 601

    BrianBaughn

    Joined:
    Feb 13, 2011
    Location:
    Baltimore, Maryland
    #9
    If they had I think it would have been by accident!

    Did you try deleting the Keychain entries for the wifi network that you don't want on that single account? Or have you done that and it's asking for the password?
     
  10. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #10
    Thanks for your solution.
    When I run it in Apple script editor, it tells me that en0 is not a Wi-Fi interface.

    No, I'll try this now.

    ----------

    Even if I delete from the keychain, it still connects to the wrong wifi network. :confused:
     
  11. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #11
    Try en1. en0 is wifi on my Air. I suspect you are on an iMac and wifi is en1.
     
  12. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #12
    No, on a regular Macbook and en1 gives the same result.
     
  13. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #13
    Hmmm... go to System Prefs Network pane then select the wifi then click advanced then the hardware tab and note the MAC address.

    Then go to Terminal and enter ifconfig. Scroll through the output to find the interface that matches the MAC address from system prefs.

    [​IMG]

    Are you sure you entered en0 (zero) and not the letter O. en0 should be the wifi on a Macbook.

    Also, if you SSID has spaced in it you will need to surround the SSID name with single quotes.
     
  14. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #14
    Thanks.

    I'm actually having some success with an applescript that selects menu items that I found here: https://discussions.apple.com/message/22231411

    Script:

    Code:
    tell application "System Events"
        tell process "SystemUIServer"
            click (menu bar item 1 of menu bar 1 whose description contains "Wi-Fi")
            click menu item "NETGEAR" of menu 1 of result
        end tell
    end tell
    This does indeed switch the wifi network over.

    What I'd like now is to create a logout script to switch it back, but I don't know how to write that.

    Also, if the script could execute silently (not keep the Apple script editor open after running), that would be great.
     
  15. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #15
    I saw that looking around earlier. You would need to run it in the other accounts at login to select their wifi.

    I don't get why you can't get the script I posted to work. I just tested again on my machine and it works perfectly.

    Try what I suggested to verify you are on the correct network interface. The fact you are getting that error just means you have identified the wrong one and it should be easy to ID the correct one like I explained.
     
  16. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #16
    Thanks, I'm sure your code does work. I just want to try tinkering with the menu selection one first.
    I'll then try with your code.

    Thanks for your help! :)
     
  17. InfiniteLoopy thread starter macrumors 6502

    Joined:
    Dec 14, 2010
    #17
    So I tweaked the previous script (I am a complete Applescript beginner) and am providing it for anyone else who may want to do this. If anyone wants to improve it, I'd love to see any improvements.

    Essentially, I wanted a script that would switch to a defined wifi network and then once it had switched, load Chrome.

    As some of the available networks take time to display in the wifi list, I've made the script repeat until it sees the desired one in the script.
    I've also added a delay of 10 seconds to make sure the OS has time to connect to the network before loading Chrome. I feel this could be improved.

    Again, I'd be interested in any improvements.

    Code:
    tell application "System Events"
    	tell process "SystemUIServer"
    		click (menu bar item 1 of menu bar 1 whose description contains "Wi-Fi")
    		repeat until menu item "Wifinetwork" of menu 1 of result exists
    		end repeat
    		set result to (menu bar item 1 of menu bar 1 whose description contains "Wi-Fi")
    		click menu item "Wifinetwork" of menu 1 of result
    		set result2 to "Success"
    	end tell
    end tell
    delay 10
    if result2 is "Success" then
    	tell application "Google Chrome.app"
    		activate
    	end tell
    end if
    
     

Share This Page