[X-Unix] automounting when a network becomes available

Stroller MacMonster at myrealbox.com
Wed Mar 16 03:12:16 PST 2005


On Mar 16, 2005, at 3:26 am, John Harrold wrote:

> Sometime in March Jerry Krinock assaulted the keyboard and produced:
>
> | tell application "Finder"
> |     mount volume "afp://sn:password@10.0.1.201/Macintosh HD/"
> | end tell
> |
> | where:
> |    sn is a short user name on the desired volume
> |    password is the user's password
> |    10.0.1.201 is its IP address of the desired volume
> |    Macintosh HD is its name
> |
> | Yeah, I know that putting a password in a script like this is not 
> good
> | security.
>
> Sorry if this seems a little basic, but where would I put the script?
> Should I put it in cron, or is this something that goes directly into 
> OS X?
> To give you a better understanding of where I'm coming from. I've 
> spent the
> last 7 years using only Linux, more or less, and I'm not really up to 
> speed
> on all the nuances and features of OS X.

I'd put it in cron, to check every 5 minutes & mount the folder if it 
exists. That means you need a bit more code than John has given. To 
mount a Windows share you would use `mount volume 
"smb://sn:password@10.0.1.201/Macintosh HD/"`

I'm not sure if Applescripts can be called from cron, so I might put 
what he's provided in a Bash wrapper-script. This page 
<http://tinyurl.com/5rzub> demonstrates how to use `osascript` to call 
an Applescript from a Bash script.

If you wanted to be really clever you could tell the Applescript to get 
the password from Keychain Access, although I probably wouldn't feel 
the necessity myself & would probably put it in the script the same as 
John has. I have a copy of "Applescript - the definitive guide here", 
and I'd be interested in implementing this, so if you don't get it 
sorted yourself email me off list everyday (set a cron job) until I 
come up with something - I'm in the middle of stuff at the moment, so 
it's likely to be a week or two until I have the hour or two I'd 
require to wrap my head around the problem.

Stroller.



More information about the X-Unix mailing list