+ Reply
Results 1 to 2 of 2
  1. #1
    Developer n00neimp0rtant's Avatar
    Join Date
    Feb 2008
    Location
    Oakland, Pittsburgh, PA
    Posts
    1,316
    Thanks
    24
    Thanked 595 Times in 135 Posts

    Default Create Wifi network through Terminal

    How can I replicate the "Create Network..." option under the AirPort icon on the menu bar in Terminal? I want to start an ad hoc network through Terminal.

  2. #2
    Developer/Hacker JStraitiff's Avatar
    Join Date
    Oct 2008
    Location
    Buffalo, NY
    Posts
    2,391
    Thanks
    81
    Thanked 283 Times in 214 Posts

    why cant you just use the menu button?

    im not sure exactly how to do it but heres how to do it with apple script



    -- This script creates an ad-hoc network with a password and changes your
    -- network location.
    --
    -- I just added network passwords and network locations to a script which
    -- comes from StefanK:
    -- MacScripter / creating ad-hoc airport network from script

    -- Set NetworkName to be the name of the wireless network you wish
    -- to create. This will also attempt to set the network location
    -- to that name as well.
    -- Set NetworkPassword to be your wireless network password. It MUST BE
    -- 13 characters long (or 26 hex digits).

    property NetworkName : "MyAdHocNetwork"
    property NetworkPassword : "thirteenchars"


    property CreateMenuName : "Create Network…"

    try
    do shell script "/usr/sbin/scselect " & NetworkName
    delay 2
    end try

    tell application "System Events"
    tell process "SystemUIServer"
    tell menu bar 1
    set menu_extras to value of attribute "Aescription" of menu bar items
    repeat with the_menu from 1 to the count of menu_extras
    if item the_menu of menu_extras is "Airport Menu Extra" then exit repeat
    end repeat
    tell menu bar item the_menu
    perform action "AXPress"
    delay 0.2
    perform action "AXPress" of menu item CreateMenuName of menu 1
    end tell
    end tell
    repeat until exists window 1
    delay 0.5
    end repeat
    tell window 1
    keystroke NetworkName
    click checkbox 1
    keystroke NetworkPassword
    keystroke tab
    keystroke NetworkPassword
    click pop up button 2
    click menu item 2 of menu 1 of pop up button 2
    delay 0.5

    click button 1
    end tell
    end tell
    end tell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts