Applescript to Auto-Mount a SMB Share

I’ve tried damn near everything to get my smb shares to mount and stay freaking mounted, but to no avail.  The last solution I tried involved modifying the /etc/fstab file and all that did was cause my mac to crash when the share randomly became unavailable.  Yesterday, I wrote a simple Applescript that had:

mount volume ‘smb://user:pass@server/MyShare’

and everytime I noticed the share would drop, I’d re-run that line and everything was pretty good.  

Today, with a little patience and some Google-Fu, I found and modified this script: http://dae.cyberic.eu/blog/applescript-to-mount-unmount-a-drive/ to resemble the following:

property minutesBetweenSaves : 0.5

on run
	tell application "GrowlHelperApp"
		set the allNotificationsList to {"Disk mounted"}
		register as application "Disk Mounter" all notifications allNotificationsList default notifications allNotificationsList icon of application "Disk Utility.app"
	end tell
	tell application "GrowlHelperApp" to notify with name "Disk mounted" title "About to start monitoring the MyShare mount" description "I'll update you in a few when I finish my first checksee" application name "Disk Mounter" icon of application "Disk Utility.app"
end run

on idle
	set myVolumeLabel to "MyShare"
	set myMountString to "smb://user:pass@server/MyShare"
	tell application "Finder"
		if not (disk myVolumeLabel exists) then
			mount volume myMountString
			tell application "GrowlHelperApp" to notify with name "Disk mounted" title "Volume mounted" description "Disk “" & myMountString & "” with volume “" & myVolumeLabel & "” has been successfully mounted." application name "Disk Mounter" icon of application "Disk Utility.app"
		end if
	end tell
	return minutesBetweenSaves * 60
end idle

on quit
	continue quit
end quit

Read the article above for a better understanding of the “big picture”, but in a nutshell, this script is meant to be saved as an application with “stay open” checked.  When it runs, it’ll do the “on run” section and register itself with Growl then let you know its about to try to mount your share.  Then, it moves into the idle section and checks to see if the volume “My Share” exists.  If not, it will run the “mount volume” command from above and let you know that its done.  This part of the script repeats every 30 seconds until I close the application.  

Hope it helps someone out there.  If so, shoot me and the page above a comment.

Thanks!

Tags: applescript apple samba/smb

1 year ago | Permalink

Three Bookmarklets for Zuda.com’s Competition Pages

My friend and designer of nearly every application I develop, Darrin Stephens, had his comic Aliens vs Ninja vs Samurai accepted into Zuda’s February “Zuda Contest”.  If he wins he’ll land a contract with DC Comics for 52 pages of the comic which they will print and sell in a trade.  This would be Huge for Darrin, so, I’m doing what I can to help him with social marketing, gadgets, and whatever else we can come up with.

I got to looking at the results page, here’s a place where a little bookmarklet might come in handy.  This one:

Sort by Results (drag this link to your bookmark bar)

allows you to sort the results page: http://zudacomics.com/competition/results by the number of views each has had.  While this doesn’t indicate that an individual entry is winning, I would estimate that the ones with the greatest traffic will be in the top of the competition.

Once again, this isn’t much, but it was fun to do.  Darrin mentioned that the one thing that really sucks about Zuda’s website: http://zudacomics.com/node/1714 is that you can’t see the strip on the iPhone.  While the HTML5 vs Flash argument has been played out by many smarter than me, it still sucks that the iPhone, and the future iPad will never have flash.  So, I made this one:

iPhone-ify (drag this link to your bookmark bar)

While it too is pretty simplistic, it does add a bit for the iPhone.  It replaces the flash <object> tag with two div’s and an <img> tag.  The image’s URL is set, dynamically, to the first image of that entry’s comic.  the div’s have a previous and next button to navigate the pages.  Once again, simple, but effective.

If anyone uses these, it’d be nice to hear about  it in the comments.  Have a good one.

Tags: iphone zuda zudacomics alienant bookmarklet apple adobe flash comics

2 years ago | Permalink

iPhone Earring Giveaway = Apple Fanboy/girl Awesome

iphone earrings

Whilst float’n down the intertube, I happened upon a TUAW post about some jewelry made from dead mac/iphone parts.  I’ve got to say, its some pretty awesome stuff for those in love with all things Apple and Geeky.  The company that makes them, Powerbook Medic, is giving away 15 sets to people willing to “working girl” their social networks in an effort to advertise the give-a-way.  Today, I am a “working girl”.

Check: http://www.powerbookmedic.com/wordpress/?s=&x=12&y=5 for more information.

Tags: apple life

2 years ago | Permalink