eigene IP-Adresse per AppleScript auslesen

hessijames

Mitglied
Thread Starter
Dabei seit
02.01.2004
Beiträge
23
Reaktionspunkte
0
Ich würde gerne die dynamische IP-Adresse eines Macs auslesen, der per DSL im Internet hängt.
Hintergrund: IP-Adresse per Mail verschicken, um dann darüber ARD-Zugriff zu bekommen.

Aber wie lese ich die IP-Adresse aus?
 
wieso registrierst du dich denn nicht einfach bei einem dynamischen dns dienst und gibst dir einfach eine domain a'la hessijames.dyndns.org?

kuckmal bei dyndns

software, die dyndns mitteilt, wenn sich deine ip geändert hat, gibts bei versiontracker*und ist kostenlos

hth
sbx
 
Also ohne jetzt ein richtiges Skript ueberlegt zu haben:

Du kannst mit
Code:
 do shell script("ifconfig")
die gesamte IP-Konfiguration auslesen. Dann nach der Zeile inet suchen und den Eintrag per
Code:
 tell application "Mail" usw...
eine neue eMail schreiben.

So ganz grob sollte das so gehen koennen.
 
Da bekommst du u.U. lokale IPs wie 10.0.1.2, mit denen du nix anfangen kannst. Ich hab mir mal ein quick & dirty Script geschrieben, das die Seite whatsmyip.com aufruft und die IP rausfischt:

Code:
tell application "URL Access Scripting"
	download "http://whatismyipaddress.com/" to file ((path to desktop as string) & ".whatsmyip.html") replacing yes
end tell

set myfile to result

open for access myfile
set mychunk to read myfile
close access myfile

set myoffset to offset of "Your IP address is" in mychunk
set mychunk to text myoffset thru -1 of mychunk
set mychunk to the 5th word of mychunk
tell application "Finder" to delete myfile

display dialog "Your IP is " & mychunk buttons {"Cancel", "Copy to Clipboard"} default button 2

if button returned of result is "Copy to Clipboard" then set the clipboard to mychunk

Vielleicht nützt das ja irgendwem. :)
 
Zuletzt bearbeitet:
gefunden bei macscripter.net

set check to do shell script "/usr/bin/curl http://checkip.dyndns.org/"
set craptalk to check
set a to "" & craptalk

set AppleScript's text item delimiters to ": "
set b to the second text item of a
set c to b
set AppleScript's text item delimiters to "<"
set x to the first text item of c

display dialog "Your external (WAN) IP address is: " & x buttons {"to clipboard", "ok"} default button 2

if result is {button returned:"to clipboard"} then
set the clipboard to x
end if
 
oder du benutzt das istat widget

da steht unter "network" die interne und externe IP
 
Zurück
Oben Unten