AppleScript to check IP of local Machine then Backup

Joined
Mar 14, 2009
Messages
7
Reaction score
0
Points
1
Hi,

My MBP is on multiple networks everyday for work and i'd like a script that checks the IP address of my MBP (wireless & wired) and if in a certain subnet, initiate a backup. I have an applescript that mounts my NAS however it would be good to have something that first checks the network i'm on, if home then mount my NAS and run a backup.

Thanks in advance for your help.

Ash.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
OP
A
Joined
Mar 14, 2009
Messages
7
Reaction score
0
Points
1
I can do a "ifconfig en0" to get the details of the interface, i'm curious how i can store and present the 'inet' value, which is the IP Address, as a variable which i can then use later in another script?
 
Joined
Mar 16, 2009
Messages
1
Reaction score
0
Points
1
Use the "set" command, for example:

set ipaddress to do shell script "ifconfig en1 | grep 'inet' | awk '{print $2}'"

Once you have this done, you can use it in same script.
 
OP
A
Joined
Mar 14, 2009
Messages
7
Reaction score
0
Points
1
Thanks Talcon, is there a way to specifically only print the IP address, i received this when ran:

"fe80::21b:63ff:feb8:e207%en0
13.201.180.161"
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top