Apple Windows Network File Sharing, how to perma mount?

Discussion in 'Software' started by unrealhippie, 25 Feb 2007.

  1. unrealhippie

    unrealhippie What's a Dremel?

    Joined:
    24 Jul 2004
    Posts:
    1,261
    Likes Received:
    1
    'Windows Network File Sharing, how to perma mount?'

    Hopefully the title explains what I mean, I am using the 'connect to server' and 'smb://windowsmachine' to mount my folders and external harddrive connected to the PC.

    Anyways, after a reboot you have to reconnect. The only solution I have found is to drag a shortcut of the folder into another place and then clicking will open the file sharing.

    But really, being lazy/over demanding I want it to connect to my folders automatically on boot. Now I have never done any script work in Mac OS X - would somebody please explain if my idea is on the right lines or if there is an easier method?

    Thanks!
     
  2. Firehed

    Firehed Why not? I own a domain to match.

    Joined:
    15 Feb 2004
    Posts:
    12,574
    Likes Received:
    16
    I know there's some bizarre hack to try accomplishing this, but I've had just about no luck myself. I think the closest I ever got was something to the effect of dragging the share into the Startup Items section of the Accounts prefpane. Hopefully someone has a better solution - it's twice as bad for me, as I've got my iTunes library on a network share, and I hope to put my Aperture library on one too (and anything else that devours hard drive space) and I have to take the laptop to classes, where accessing said shares is unreliable at best.

    Anyways, I'd give the startup items thing a try - it may work well enough for you. Worth a try - worst case is that you wasted two minutes rebooting.
     
  3. Hiren

    Hiren mind control Moderator

    Joined:
    15 May 2002
    Posts:
    6,131
    Likes Received:
    13
    I've been wanting to do the exact same thing, it's annoying how OSX doesn't do useful things like that.

    I'll try the startup shizzle.
     
  4. GreatOldOne

    GreatOldOne Wannabe Martian

    Joined:
    29 Jan 2002
    Posts:
    12,092
    Likes Received:
    112
    There is a way of doing this with apple script... I had my windows shares (when I had a windows box) mounting this way, and now I mount my remote drives on my Mac Mini in the same sort of way.

    I'm a little fuzzy on this as the files are at home and it's been a while since I set it up but I think it goes something like this:

    tell application "Finder"
    try
    mount volume "smb://yourshareddirive"
    end try
    end tell

    Save that as an executable apple script and put that in your start-up items. When OSX starts up, it should mount the drive as an icon on your desktop. It may (or may not - I can't remember if this is the right version) pop open a finder window for each drive mounted. I think this is the one where it'll just mount and give you an Icon - I believe if you swap the keyword "mount" for "open" that'll give you the finder window.

    Have a go and see what happens. I'll post exactly what I have in my scripts when I get home (and if I rememember!)
     
  5. unrealhippie

    unrealhippie What's a Dremel?

    Joined:
    24 Jul 2004
    Posts:
    1,261
    Likes Received:
    1
    Perfect mate, unfortunately the other easy peasy method of dropping onto start up items makes them open and pop up even when you click hide!

    Any other wonderful insights to share? :hehe:
     
  6. GreatOldOne

    GreatOldOne Wannabe Martian

    Joined:
    29 Jan 2002
    Posts:
    12,092
    Likes Received:
    112
    Glad it worked. I got annoyed with finder windows popping open on startup ( I have four drives being mounted), hence the script. If you have remote OSX drives to mount use this fragment rather than the SMB mount:

    tell application "Finder"
    mount volume "afp://login:password@ServerNameOrIPAddress/DriveName"
    end tell

    I believe the login & password will also work on SMB shares:

    smb://login:password@yourpc/sharedrive

    Although I reserve the right to be wrong on that... :)
     
  7. Firehed

    Firehed Why not? I own a domain to match.

    Joined:
    15 Feb 2004
    Posts:
    12,574
    Likes Received:
    16
    I would think so, although I just keep them stored in the keychain. Thanks a ton GOO (and unreal for tweaking it) - so much better than my old cmd+k several times method.
     
  8. Seth

    Seth What's a Dremel?

    Joined:
    14 Mar 2002
    Posts:
    869
    Likes Received:
    0
    Thanks I was like the above user and did the cmd + k method. this saved time and I learned how to make a simple apple script.
     
  9. GreatOldOne

    GreatOldOne Wannabe Martian

    Joined:
    29 Jan 2002
    Posts:
    12,092
    Likes Received:
    112
    I had another tinker last night, as one of the side effects of doing it this way is you can get into the situation that the applescript fires off on startup, but the network isn't up and running yet. This script waits for the network, pauses for a couple of seconds and then attempts the mount.

    Code:
    set netAvailable to false
    
    -- wait for network to be available, by issuing a shell command to run ifconfig. en0 = wired port, en1 = airport. 
    repeat until netAvailable = true
         set netAvailable to (do shell script "ifconfig en0 | awk '/inet/ {print $2}'") is not equal to ""
    end repeat
    
    -- pause to ensure the net is fully up
    delay 3
    
    -- mount the drive
    tell application "Finder"
         try
              -- mount a windows share
              mount volume smb://login:password@yourpc/sharedrive 
              -- mount an OSX share
              mount volume afp://login:password@ServerNameOrIPAddress/DriveName"
         end try
    end tell
    
    That works for me... I originally had a two minute timeout on the mount so I could ensure the net was up and it'd work, but this just wasted time and gave me an annoying beach ball of doom. This way it waits for the network before attempting the mount, without any spinning inflatables. :D
     
    Last edited: 27 Feb 2007
  10. Hiren

    Hiren mind control Moderator

    Joined:
    15 May 2002
    Posts:
    6,131
    Likes Received:
    13
    Great script GOO, I just used it (first time scripter) works brilliant.
     
  11. unrealhippie

    unrealhippie What's a Dremel?

    Joined:
    24 Jul 2004
    Posts:
    1,261
    Likes Received:
    1
    Just added some quotes to stop the errors I was getting, works great, Cheers!
     
  12. Hiren

    Hiren mind control Moderator

    Joined:
    15 May 2002
    Posts:
    6,131
    Likes Received:
    13
    Is there anyway to change the location of the default Front Row folders using this method? I.e. "Movies" so I can access all my videos streamed right off the PC from within Front Row?
     
  13. GreatOldOne

    GreatOldOne Wannabe Martian

    Joined:
    29 Jan 2002
    Posts:
    12,092
    Likes Received:
    112
    I got this from Mac OSX Hints :

    So I guess that you can make an alias to your remote server drive and drop it into your movies folder. Give it a go.
     
  14. Hiren

    Hiren mind control Moderator

    Joined:
    15 May 2002
    Posts:
    6,131
    Likes Received:
    13
    Woa thanks GOO, works like a champ. Even the preview window worked well, had no trouble streaming some 700mb DIVX across. One thing I did find was that initally Front Row dumped itself back to the desktop (although this could be due to my kvm or bad reception for the remote). I've tried it a few times now and had no issues.

    Looks like my mini just became the perfect streaming box as well.
     
  15. Firehed

    Firehed Why not? I own a domain to match.

    Joined:
    15 Feb 2004
    Posts:
    12,574
    Likes Received:
    16
    Indeed - that needs to be done with aliases. Unfortunately, it only works with movies as far as I know, not pictures and music (which rely on iPhoto and iTunes libraries respectively). If you want to offload all of your media (as to not clog up a tiny hard drive in the Mini or a notebook), just set the respective apps to save their library files on the network share :)
     
  16. Hiren

    Hiren mind control Moderator

    Joined:
    15 May 2002
    Posts:
    6,131
    Likes Received:
    13
    Actually Firehed (did your name change?) that was going to be my next question. How exactly do you change the libraries?
     
  17. Firehed

    Firehed Why not? I own a domain to match.

    Joined:
    15 Feb 2004
    Posts:
    12,574
    Likes Received:
    16
    Name change? Uhh.... not in the last 5+ years.

    Anyways, when you start iTunes, hold down the option key. I have no idea for iPhoto as I never use it, but I wouldn't be surprised if it's the same; if not, check preferences.
     
  18. Hiren

    Hiren mind control Moderator

    Joined:
    15 May 2002
    Posts:
    6,131
    Likes Received:
    13
    Meh must just me having a strange moment.

    Ok thanks for that I'll give it a whirl.
     
Tags:

Share This Page