|
|
Mount and unmount server shares via AppleScript
I've written a simple bash script that outputs a space-delimited list of all IP addresses bound, across all ethernet adapters. You can either call the script by itself to return that list, or pass it an IP address as the sole argument, in which case it returns the IP address if it's bound, or nothing if it isn't.
Check it out:
#!/bin/bash
# echo a list of all bound IPs
#
ISIP_TEMP=`ifconfig -u | grep -w "inet" | awk '{printf " " $2}'`
if [ $1 ]; then
if [ -n "`echo $ISIP_TEMP | grep -w $1`" ]; then
echo $1
fi
else
echo $ISIP_TEMP
fi
unset ISIP_TEMP
I actually use this script in a handful of other scripts. I hope it's helpful! - Cowboy ---
an example:
I thought I'd provide an example of usage. I named the script in the parent post isip, put it in the path, and made it executable, so it's accessible to any of my scripts.
#!/bin/bash if [ `isip 192.168.0.70` ]; then open ~/bin/myscript_network_home else open ~/bin/myscript_network_work fi Since I've configured my home DHCP server to reserve 192.168.0.70 for my laptop, and that address doesn't fall into the DHCP pool at work, this script can easily tell which network I'm on and run the right app, automagically! - Cowboy --- |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.10 seconds |
|