Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting IP Address in OS X

58 views
Skip to first unread message

Al Hatch

unread,
Jan 6, 2003, 3:48:53 PM1/6/03
to
Is there any way for Applescript to acquire the machine's current dynamic IP
Address locally in OS X?

All the solutions I've seen so far either query web sites, or require OS 9.

System Preferences' dictionary claims it will open a pane, but Applescript
claims "pane" is an undefined variable.

In Terminal, you can type

ifconfig -a

to see your current IP address and associated information.

Is there a way to script Terminal to copy the IP Number to the clipboard?

Al Hatch

Tony Lawrence

unread,
Jan 6, 2003, 4:04:36 PM1/6/03
to

pipe it to pbcopy

ifconfig -a | pbcopy


--
Tony Lawrence
Free SCO and Linux Skills Tests: http://aplawrence.com/skillstest.html

Patrick Stadelmann

unread,
Jan 6, 2003, 4:29:51 PM1/6/03
to
In article <EbmS9.587097$P31.210806@rwcrnsc53>,
Tony Lawrence <to...@pcunix.com> wrote:

> pipe it to pbcopy
>
> ifconfig -a | pbcopy

The just use the "do shell script" command in AppleScript (its in
Standard Additions).

Patrick
--
Patrick Stadelmann <Patrick.S...@unine.ch>

Koncept

unread,
Jan 6, 2003, 4:59:37 PM1/6/03
to
set myip to ¬
do shell script "ifconfig | grep 'broadcast' | awk '{print $6}'"
display dialog ¬
"Your IP address is:" default answer (myip) with icon note

::::or::::

set TheResult to (do shell script "curl -f http://checkip.dyndns.org")
set Olddelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "Current IP Address: "
set LongIP to item 2 of every text item of TheResult
set AppleScript's text item delimiters to return
set myip to item 1 of (every text item of LongIP)
display dialog "Your IP is : " default answer (myip) with icon note
set AppleScript's text item delimiters to Olddelim

in article Patrick.Stadelmann-8...@news.fu-berlin.de,
Patrick Stadelmann at Patrick.S...@unine.ch wrote on 1/6/03 4:29 PM:

Al Hatch

unread,
Jan 7, 2003, 12:02:52 PM1/7/03
to
Thank you, gentlemen. For some reason I had been avoiding a shell script, but
it works like a charm.

Tony Lawrence wrote:
pipe it to pbcopy

ifconfig -a | pbcopy

Patrick Stadelmann wrote:
The just use the "do shell script" command in AppleScript (its in
Standard Additions).

Koncept wrote:

On Mon, 6 Jan 2003 13:59:37 -0800, Koncept wrote
(in message <BA3F6678.18470%the_...@nospam-hotmail.com>):

0 new messages