Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to do IP-based mounting and indexing Apps
Ingredients for making a magic auto-mounter:
  • 1 User Editable
  • 2 parts IP Detection
  • 2 parts Share Mounting
  • 2 parts Share Indexing
Throw it all together in an AppleScript, press liquify.

But what does it do, really? It does this:
  1. Detects your WAN IP.
  2. Asks you what you want to do, Mount and Index, Just Mount, Nothing (as well as conveniently showing your IP).
  3. Mounts the shares associated with your IP
  4. Runs mdutil -i on the shares (Indexing them if you wanted to).
You will have to enter your password to index the new shares.

[robg adds: I haven't tested this one.]
    •    
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[5,702 views]  

An AppleScript to do IP-based mounting and indexing | 7 comments | Create New Account
Click here to return to the 'An AppleScript to do IP-based mounting and indexing' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to do IP-based mounting and indexing
Authored by: adammhaile on Feb 14, '07 08:25:18AM

ummm....link to the script is dead! Please fix. I would really like to try this out. Been looking for just this for this ever wince I made the switch.
Thanks



[ Reply to This | # ]
An AppleScript to do IP-based mounting and indexing
Authored by: redclawx on Feb 14, '07 08:57:05AM

I get a file not found as well.



[ Reply to This | # ]
An AppleScript to do IP-based mounting and indexing
Authored by: robg on Feb 14, '07 09:43:21AM

Sorry, fixed now.

-rob.



[ Reply to This | # ]
An AppleScript to do IP-based mounting and indexing
Authored by: cmv on Feb 14, '07 02:19:36PM

The script as posted doesn't compile. I think there may be a line or two missing from near the top ... specifically, the doMounting() definition.



[ Reply to This | # ]
An AppleScript to do IP-based mounting and indexing
Authored by: lar3ry on Feb 15, '07 04:37:30AM
There is a line that reads:
-- alter this to work with your above changes.on doMounting()
Split the line after the period and before the word "on."

I've done similar things based on IP address, but since my work IP is DHCP and relatively random, I check via regular expression, although checking via netmask would be just as usable. Applescript doesn't have all the juice needed for this, but if you augment with shell scripts, you can do quite a lot of things.

I needed to modify my script for a special case where I traveled somewhere and the IP address I received made it appear that I was at home. I got around this by making a tweak to do a "one shot ping" of a system that should be always reachable on my home LAN in order to differentiate between being "home," "in the office," or "visiting."

Doesn't that sound like network "locations?" [smile]

I can think of some other interesting things that such a script can do, once it knows where you are:

  • Play a shell game with Finder aliases so that my Finder sidebar "Favorites" contains things that I would normally use at that particular location.
  • Set the networking Location, if applicable.
  • Set up Quicksilver or Butler shortcuts that are applicable to the location.
The list is really limitless, depending on your needs. Perhaps somebody will create some sort of utility so that people don't need to be programmers to do this fancy stuff!

As for the script presented, I honestly never considered turning Spotlight on the shares I mount. Silly me! (And great idea! I may add that to my own script!)

[ Reply to This | # ]

how to get it to work behind a proxy
Authored by: b.leopard on Feb 16, '07 08:43:46AM
First of all you have to fix broken linebreaks. There should be one before on doMounting() and after -- start modified from Daniel Veinerset. After that the script will compile. But: This script doesn't handle any error - and there are several possibilities for errors and if you are like me behind a proxy, don't run it now. The curl-command causes an endless hangup as long as you haven't added --proxy proxyhostname:portnumber. Unfortunately this is not a real solution, because you will have that problem again at home. I think there should be a ping-testing to detect the environment.

[ Reply to This | # ]
An AppleScript to do IP-based mounting and indexing
Authored by: Stef@nK on Feb 17, '07 02:41:20AM
Hi,
to detect an external IP in AppleScript, you can also use this one-liner:

set ip_external to text 2 thru -1 of 
		(do shell script "curl http://checkip.dyndns.org | cut -f 2 -d ':' | cut -f 1 -d '<'")


[ Reply to This | # ]