View Full Version : script to open file shares

23rd March 2008, 03:38 PM
hey guys
wondering if you could help me?

am trying to get around a file sharing issue, where to connect to my vista server, i need to 'connect to server'...

cause everytime i want to use front row, and access my movies/tv rips etc, i need to follow this process, when im thinking it would be MUCH simpler if i could double click on a script on my desktop that would automatically open up these shares?

i have tried automation, so that on login, it tries to connect, but this is annoying as hell when im not at home...

can anyone point me in the right direction, or talk me through how to right a script to this extent? as i have no idea where to begin??

cheers guys


23rd March 2008, 04:00 PM
Umm executing the following from a Terminal session would do it;

osascript -e "try" -e "mount volume \"smb://user@server/share\"" -e "end try"

EDIT: of course the user's password for the share would have to be already saved into your keychain.

23rd March 2008, 04:06 PM
FANTASTIC, works a treat..

in terms of writing scripts, im a bit of a noob...

how would i save this in a file to make it executable on my desktop??

Thanks so much for the help, wicked stuff..

23rd March 2008, 04:13 PM
You can do the same in Automator and save the workflow as an application.

1. Add action "Get Specified Servers"
2. Click 'Add' and add the server path or click on mounts already showing"
3. Add action "Connect to Servers"
4. Save as Application

You can put this in your startup items or somewhere you would like to double-click and the shares will be mounted without opening a Finder window.

23rd March 2008, 04:22 PM
that is awesome!!

thanks heaps, tried it out and works perfect.. thanks for your help, automator looks VERY powerful!!

1st April 2008, 07:42 AM
little suggestion...try this in script editor....

tell application "Finder"

if exists folder "NAME_OF_SHARE" in desktop then
display dialog "NAME_OF_SHARE is already mounted." buttons "OK" giving up after 5
set mount1_conn to false
set loopcount to 1
repeat until mount1_conn is true or loopcount is greater than 3
if exists folder "NAME_OF_SHARE" in desktop then
set mount1_conn to true
mount volume "PUT ADDRESS HERE (CAN BE SMB, AFP,...ETC. EX.: smb://" as user name "UNAME" with password "PASSWORD"
end try
delay 1
set loopcount to loopcount + 1
end if
end repeat
end if

end tell

this will check to make sure that it's not already mounted, then connect and mount. if it is mounted already, it will pop up a box and tell you so, if not, it will mount it. it will attempt it three times if there's a connection issue then quit.

1st April 2008, 09:06 AM
Cheers MD, great script