Skip navigation
This discussion is archived

command line: how to connect to wifi and choosing ssid

8744 Views 13 Replies Latest reply: Mar 8, 2010 3:58 PM by stpauli RSS
stpauli Calculating status...
Currently Being Moderated
Mar 7, 2010 6:00 AM
hi,

does anybody know how to connect to wifi and a specified ssid using the command line? There used to be a command ">airport -A --associate", but it does not seem to work anymore...is there any other way such as an applescript that can do it?

thks
MacBookPro4,1, Mac OS X (10.6.2)
  • BobHarris Level 6 Level 6 (12,505 points)
    If you know in advance the network you will be associating with (like you switch between Home, Work, Panera, Starbucks, etc...), you can setup System Preferences -> Network -> Locations, then use the scselect command. For example:

    scselect "Home Location Name"
    scselect "Work Location Name"
    scselect "Panera Location Name"
    # etc...

    Each location can has its own preferred networks, as well as proxy settings, fixed vs DHCP IP address assignment, DNS servers, etc...

    I would experiment with the Airport command, but I'm in a Panara on a 10.5.8 Leopard system at the moment. My 10.6.2 Snow Leopard system is at work
    MacBook, iMac/i7, PowerMac/G5, Mac mini, iBook/G4, MacBook Pro, iMac/G4, Mac OS X (10.5.8), iPod Touch
  • BobHarris Level 6 Level 6 (12,505 points)
    I do not know if this helps, but apparently the airport program has another mode of operation. Try issuing the following command:

    airport help

    NOT --help, but just help

    I don't know if this will be useful, but it is more than we knew before.
    MacBook, iMac/i7, PowerMac/G5, Mac mini, iBook/G4, MacBook Pro, iMac/G4, Mac OS X (10.5.8), iPod Touch
  • doug pennington Level 3 Level 3 (815 points)
    Have you tried that command with sudo?
    ibook g4(PantherX.3.9),ibookg3(TigerX.4.11),PMacG4QuickSilver(LeopardX.5.8)
  • BobHarris Level 6 Level 6 (12,505 points)
    Have you tried that command with sudo?

    I have, and I get the longer Usage message I mentioned above (this is on Snow Leopard).
    MacBook, iMac/i7, PowerMac/G5, Mac mini, iBook/G4, MacBook Pro, iMac/G4, Mac OS X (10.5.8), iPod Touch
  • doug pennington Level 3 Level 3 (815 points)
    So in Snow Leopard it won't come up as it does in Leopard as such:

    doug-penningtons-power-mac-g4:~ dougp$ sudo airport -A --associate
    Network Name (SSID):

    ?
    (password had already been supplied above within last 5 minutes)
    ibook g4(PantherX.3.9),ibookg3(TigerX.4.11),PMacG4QuickSilver(LeopardX.5.8)
  • BobHarris Level 6 Level 6 (12,505 points)
    So in Snow Leopard it won't come up as it does in Leopard as such:

    doug-penningtons-power-mac-g4:~ dougp$ sudo airport -A --associate
    Network Name (SSID):

    No. It does not. It generates a long Usage message when you try to use -A and or -A --associate.

    sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -A --associate

    airport: invalid option -- A
    airport: unrecognized option `--associate'

    Usage: airport <interface> <verb> <options>

    <interface>
    If an interface is not specified, airport will use the first AirPort interface on the system.

    <verb is one of the following:
    prefs If specified with no key value pairs, displays a subset of AirPort preferences for
    the specified interface.

    Preferences may be configured using key=value syntax. Keys and possible values are specified below.
    Boolean settings may be configured using 'YES' and 'NO'.

    DisconnectOnLogout (Boolean)
    JoinMode (String)
    Automatic
    Preferred
    Ranked
    Recent
    Strongest
    JoinModeFallback (String)
    Prompt
    JoinOpen
    KeepLooking
    DoNothing
    RememberRecentNetworks (Boolean)
    RequireAdmin (Boolean)
    RequireAdminIBSS (Boolean)
    RequireAdminNetworkChange (Boolean)
    RequireAdminPowerToggle (Boolean)
    WoWEnabled (Boolean)

    logger Monitor the driver's logging facility.

    sniff If a channel number is specified, airportd will attempt to configure the interface
    to use that channel before it begins sniffing 802.11 frames. Captures files are saved to /tmp.
    Requires super user privileges.

    debug Enable debug logging. A debug log setting may be enabled by prefixing it with a '+', and disabled
    by prefixing it with a '-'.

    AirPort Userland Debug Flags
    DriverDiscovery
    DriverEvent
    Info
    SystemConfiguration
    UserEvent
    PreferredNetworks
    AutoJoin
    IPC
    Scan
    802.1x
    Assoc
    Keychain
    RSNAuth
    WoW
    AllUserland - Enable/Disable all userland debug flags

    AirPort Driver Common Flags
    DriverInfo
    DriverError
    DriverWPA
    DriverScan
    AllDriver - Enable/Disable all driver debug flags

    AirPort Driver Vendor Flags
    VendorAssoc
    VendorConnection
    AllVendor - Enable/Disable all vendor debug flags

    AirPort Global Flags
    LogFile - Save all AirPort logs to /var/log/airport.log

    <options> is one of the following:
    No options currently defined.

    Examples:

    Configuring preferences (requires admin privileges)
    sudo airport en1 prefs JoinMode=Preferred RememberRecentNetworks=NO RequireAdmin=YES

    Sniffing on channel 1:
    airport en1 sniff 1


    LEGACY COMMANDS:
    Supported arguments:
    -c[<arg>] --channel=[<arg>] Set arbitrary channel on the card
    -z --disassociate Disassociate from any network
    -I --getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
    -s[<arg>] --scan=[<arg>] Perform a wireless broadcast scan.
    Will perform a directed scan if the optional <arg> is provided
    -x --xml Print info as XML
    -P --psk Create PSK from specified pass phrase and SSID.
    The following additional arguments must be specified with this command:
    --password=<arg> Specify a WPA password
    --ssid=<arg> Specify SSID when creating a PSK
    -h --help Show this help
    MacBook/10.5.8, iMac/i7/10.6.2, PowerMac/G5/10.4.11, Mac mini/10.5.6, iPod Touch, iBook/G4, MacBook Pro, iMac/G4
  • doug pennington Level 3 Level 3 (815 points)
    Thanks Bob. I wanted to see that usage info. Looks like your original answer might be the way, regardless of what op runs into.
    ibook g4(PantherX.3.9),ibookg3(TigerX.4.11),PMacG4QuickSilver(LeopardX.5.8)
  • foilpan Level 4 Level 4 (1,385 points)
    try using networksetup instead:

    example:

    /usr/sbin/networksetup -setairportnetwork AirPort openwifi
    mbp 2.4, mbp 2.16, powerbook G4 1ghz, G4 400 mhz, dell test box, etc., Mac OS X (10.6.2), plain text 4 life
  • BobHarris Level 6 Level 6 (12,505 points)
    Thanks Bob. I wanted to see that usage info. Looks like your original answer might be the way, regardless of what op runs into.

    Then why not ask for a copy of the Usage, instead of questioning my reports that -A --associate does not work in Snow Leopard?
    MacBook/10.5.8, iMac/i7/10.6.2, PowerMac/G5/10.4.11, Mac mini/10.5.6, iPod Touch, iBook/G4, MacBook Pro, iMac/G4
  • doug pennington Level 3 Level 3 (815 points)
    Excuse me if I lead you to blow this way out of context.
    ibook g4(PantherX.3.9),ibookg3(TigerX.4.11),PMacG4QuickSilver(LeopardX.5.8)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.