easy MACOS Proxy set (on-off)

Discussion in 'Mac Apps and Mac App Store' started by preswang, Jul 4, 2010.

  1. preswang macrumors newbie

    Joined:
    Jul 4, 2010
    #1
    i write an AppleScript for MACOS(SL tested) http and https Proxy on and off set.
    Maybe help someone who need it.:)
     

    Attached Files:

  2. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #2
    How very dangerous. How do we know that we can trust you? What is to top it from being a virus?

    Cool idea though and thanks for the upload if it is legit. What does it do exactly? Will you be able to read any of the info?
     
  3. preswang thread starter macrumors newbie

    Joined:
    Jul 4, 2010
  4. preswang thread starter macrumors newbie

    Joined:
    Jul 4, 2010
    #4
    hey, it's what it contains:
    you can put the code in your AppleScript

    -- Set http(s) Proxy On-Off
    -- Author: lasse
    -- MAC OS Version: OSX/SnowLeopard
    -- Date: 7/4/2010
    tell application "Finder"
    set proxy_dialog to display dialog "Set Http and Https Proxy Open or Close. Select Interface:" buttons {"AirPort On", "Ethernet On", "All off"} default button "Airport On" with title "Http(s) Proxy Settings On-off"
    set proxy_interface to button returned of proxy_dialog
    end tell

    if proxy_interface is "AirPort On" then
    do shell script "networksetup -setwebproxystate airport on"
    do shell script "networksetup -setsecurewebproxystate airport on"
    end if

    if proxy_interface is "Ethernet On" then
    do shell script "networksetup -setwebproxystate ethernet on"
    do shell script "networksetup -setsecurewebproxystate ethernet on"

    end if

    if proxy_interface is "All off" then

    do shell script "networksetup -setwebproxystate airport off"
    do shell script "networksetup -setsecurewebproxystate airport off"

    do shell script "networksetup -setwebproxystate ethernet off"
    do shell script "networksetup -setsecurewebproxystate ethernet off"
    --return
    end if
     
  5. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #5
    Haha ok good I jut assumed that it would be an app. Thanks :cool:
     
  6. merrimac macrumors newbie

    Joined:
    Jun 8, 2011
    #6
    proxy script

    Hi

    I am looking for a script like the one below to set proxies ie auto proxy file etc and to remove proxy settings thst users have had set

    the script I have is a shell script but I keep getting syntax errors

    Could someone help

    #! /bin/bash
    ###
# Network device to be managed.
# more options exist other than these, run ‘networksetup -listallnetworkservices’ from the terminal
###
if [[ `networksetup -getairportpower "Airport" | awk '{ print $4 }'` == "On" ]]; then
device=”Airport”
else
device=”Ethernet”
fi
    if [[ `scutil --proxy | grep ProxyAutoConfigEnable | awk '{ print $3 }'` == "1" ]]; then
proxyState=”enabled”
else
proxyState=”disabled”
fi
    if [[ "$proxyState" == "enabled" ]]; then
networksetup -setautoproxyurl $device ” “
networksetup -setautoproxystate $device off
proxyState=”disabled”
imagepath=”${1}Contents/Resources/proxy_disconnected.icns”
else
networksetup -setautoproxyurl $device “http://yourproxyserver.edu/proxy.pac”
proxyState=”enabled”
imagepath=”${1}/Contents/Resources/proxy_connected.icns”
fi
    capProxyState=`echo “${proxyState:0:1}” | tr a-z A-Z`
capProxyState=$capProxyState${proxyState:1}
    if [[ -e /usr/local/bin/growlnotify ]]; then
/usr/local/bin/growlnotify –image “$imagepath” -m “Proxy Server is now $proxyState.” -t “Proxy Server $capProxyState”
else
echo “$proxyState”
fi
     

Share This Page