|
|
Reposting to correct HTML
[Editor's note: I have not tested this script.]
The script below automatically finds the next IP in a list of IP addresses called ips. This list must be one IP per line, and must not have a blank line at the end (i.e. save it with the cursor on the line of the last IP). The script uses fping, although ping could be (used albeit a bit more slowly). The script discovers whether or not the target IP is in use; if it is, it goes on to the next one recursively, updating the order of the ips file each time it runs. Otherwise, it updates your en0 IP and routes appropriately, optionally calling noip (the command line interface for free dynamic dns client). It won't loop infinitely as it stops if it reaches the beginning IP in the list. Check out the comments to see where you can easily make this a one-IP, command-line-input script. #!/bin/sh
Reposting to correct HTML
This script is a bit ... well ... overly complicated. Why not just using a "for IP in `cat ${IPFILE}`" instead of the complicated mover routine? And why not simply make it a StartupItem and let it read the whole kaboozle from hostinfo, add a key named 'IP_ADDRESSES' and fill it with colon delimited values which you then split using cut, awk, sed, or something similar?
Overly complicated scripting ;p
For some purposes, that probably would be more elegant... the fashion of the script was needed because of the need I had to actually rotate through a list (rather than just searching it); if I run the script twice, I don't want to come up with the same IP. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks 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.09 seconds |
|