New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

AppleScript to check IP of local Machine then Backup


Post Reply New Thread Subscribe

 
Thread Tools
AshUk

 
Member Since: Mar 14, 2009
Posts: 7
AshUk is on a distinguished road

AshUk is offline
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.
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
Let me google that for you. This was the first hit.

You may want to choose en1 instead of en0 if you are using wireless. Or test for both.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
AshUk

 
Member Since: Mar 14, 2009
Posts: 7
AshUk is on a distinguished road

AshUk is offline
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?
QUOTE Thanks
Talcon

 
Member Since: Mar 16, 2009
Posts: 1
Talcon is on a distinguished road

Talcon is offline
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.
QUOTE Thanks
AshUk

 
Member Since: Mar 14, 2009
Posts: 7
AshUk is on a distinguished road

AshUk is offline
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"

Mac Specs: Macbook Pro 2.6 Core 2 Duo, 4GB ram, 160Gb HDD
QUOTE Thanks
AshUk

 
Member Since: Mar 14, 2009
Posts: 7
AshUk is on a distinguished road

AshUk is offline
Found it:

ifconfig en0|grep "inet "|cut -d ' ' -f 2

Mac Specs: Macbook Pro 2.6 Core 2 Duo, 4GB ram, 160Gb HDD
QUOTE Thanks

Post Reply New Thread Subscribe


« Pre-compile for dev team distribution? | how can i get a usb device's path which is mounted by system »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Time Machine backup of multiple drives? CJBB1@me.com Switcher Hangout 1 02-21-2009 12:33 AM
Ensure complete backup of data with Time Machine Ge64 OS X - Operating System 4 09-10-2008 04:16 AM
Restoring Time Machine Backup? SamJ35 Switcher Hangout 2 06-03-2008 04:16 PM
The Easiest Backup Ever mathogre Schweb's Lounge 4 03-04-2007 11:42 AM
Buy backup software or wait for Time Machine? ripfrankwhite OS X - Apps and Games 4 10-25-2006 01:43 AM

All times are GMT -4. The time now is 12:59 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?