Re: Web proxy settings?
Re: Web proxy settings?
- Subject: Re: Web proxy settings?
- From: Takaaki Naganoya <email@hidden>
- Date: Tue, 11 Apr 2006 17:13:46 +0900
- Thread-topic: Web proxy settings?
How about this code?
--
Takaaki Naganoya
Piyomaru Software
http://www.appleco.jp/piyomarusoft/
<AppleScript>
retWebProxySetting() of me
--get HTTP Proxy settings from system_profiler
on retWebProxySetting()
set pxList to do shell script "system_profiler SPNetworkDataType"
set pxList to paragraphs of pxList
set pxList to items 5 thru -1 of pxList
set pLen to length of pxList
--Parse System Profile
set typeList to {}
set tempList to {}
set i to 1
repeat
set j to contents of item i of pxList
if j = "" then
if (i + 1) > pLen then
set the end of typeList to tempList
exit repeat
else
set the end of typeList to tempList
set tempList to {}
set i to i + 3
end if
else
set j to eraseHeadSpace(j) of me
set the end of tempList to j
end if
set i to i + 1
end repeat
--Find Active Network Interface
set pxLen to length of typeList
set eqF to false
repeat with i from 1 to pxLen
repeat with ii in item i of typeList
set jj to contents of ii
if jj is equal to "Has IP Assigned: Yes" then
set eqF to true
exit repeat
end if
end repeat
if eqF = true then exit repeat
end repeat
--Case: there is no active network interface
if eqF = false then return ""
--return HTTP Proxy settings
set targetList to item i of typeList
repeat with iii in targetList
set j to contents of iii
if j begins with "HTTP Proxy Server:" then
set ansText to text 20 thru -1 of j
return ansText
end if
end repeat
return ""
end retWebProxySetting
--remove space characters
on eraseHeadSpace(a)
set aList to characters of a
set i to length of aList
repeat with ii from 1 to i
set j to contents of item ii of aList
if j is not equal to " " then
exit repeat
end if
end repeat
set aText to text ii thru -1 of a
return aText
end eraseHeadSpace
</AppleScript>
On 05.4.14 5:10 PM, "Axel Luttgens" <email@hidden> wrote:
> John Baltutis wrote:
>
>> On 04/12/05, Axel Luttgens <email@hidden> wrote:
>>
>>
>>> Tim Mansour wrote:
>>>
>>>
>>>
>>>> Can anyone point me in the right direction please: how might I
>>>> determine the current web proxy server settings from within a script
>>>> (on OS X)?
>>>>
>>>>
>>>>
>>> Those settings seem to be saved into file:
>>> /Library/Preferences/SystemConfiguration/preferences.plist
>>> by using a rather convoluted format (lots of indirections).
>>>
>>> Unfortunately, I can't manage to access its contents with the 'defaults'
>>> shell command.
>>>
>>>
>>
>> This works in Panther:
>>
>> do shell script "defaults read
>> /Library/Preferences/SystemConfiguration/preferences"
>>
>>
> Yup :-(
> I always forget that syntax; I think the man page is worth an update
> with regards to the host and domain arguments...
>
> Thanks,
> Axel
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden