# [HOWTO] Automatically mount network volumes on login



## robin.o (Jan 31, 2003)

Is there any way (short of creating a "disk" with Interarchy) that I can connect to an FTP server at startup and have it on my desktop just like a disk?  The thing is, it requires a username and password, and I don't want to use extra programs... just os x.  How do I set up the "Connect to Server..." feature to prompt me for my username and password, and how do I make it connect automatically?  Thanks


----------



## StarBuck (Jan 31, 2003)

If you go into your system preferences and open login Items and now just drag the mounted volume into this window.  

When you next login it will mount it for you.

Starbuck


----------



## wiz (Feb 1, 2003)

cool


----------



## egilDOTnet (Feb 10, 2003)

Is it possible to run a script when you put a computer in sleep mode? That is, when I close my lid to my powerbook, I would like to have all network shares dismounted! Is that possible?


----------



## Wombat (Feb 19, 2003)

Are there any additional setups to be made?
My AFP volumes work fine, but SMB and FTP don't come up.


----------



## symphonix (Mar 2, 2003)

You might try this program.

http://www.versiontracker.com/moreinfo.fcgi?id=17579&db=mac

It allows you to set a script to run when the mac sleeps or wakes up.


----------



## antadam (Jun 8, 2003)

yeah, apple's login items only work for afp volumes...it def won't work for smb...i forget why though.


----------



## profx (Jun 8, 2003)

I have this script that mounts my university SMB drive.  It is run when my powerbook wakes up.

The first part check to see if there is an ethernet cable attached, then if there is it checks the broadcast address if it is 130.216.xxx.xxx then i presume that the computer is attached the university network and then call an applescript to mount the drive.


```
#! bin/sh

# Wait for computer to figure itself out
sleep 5

status=$(ifconfig en0 | grep status | awk '{print $6}')
if((${#status}==0))
then
    exit
fi


broadcastnet =$(ifconfig en0 | grep inet |grep broadcast |  awk '{print $6}'| tr "." " ") 

oct1=$(echo $broadcastnet | awk '{print $1}' )
oct2=$(echo $broadcastnet | awk '{print $2}')

if((oct1==130 && oct2==216))
then 
    echo Mounting SMB Drive
    osascript /Users/profx/Library/Scripts/mount_smb.scpt
else
    exit
fi
```


now for the applescript:
try
mount volume "smb://_domain_;_user_@_netbiosofserver_/_share_"
end try


and.. yes it gets more complicated...

i have a file named ".nsmbrc" in my home directory with this in it

[NETBIOS_SERVER:USER:SHARE]
addr=xxx.xxx.xxx.xxx
password=*******
workgroup=DOMAIN


simple...
obviously the address is the servers ip address  and the workgroup is the domain i referred to earlier!

this mounts the drive when the computer wakes, without prompting for a password.


----------



## profx (Jun 8, 2003)

ps, if you plan on using the .nsmbrc file you must chmod it so that the permissions are this... "-rw-------" i cant remember the code to do it, but do a search for .nsmbrc and you will find a tutorial on how to do must of this!


that applescript line that says
smb://domain;user@netbiosofserver/share
you should be able to paste that in to the connect to server dialog (apple-k), it should mount without prompting for a password if you got the .nsmbrc file right


Of course this could be a useless rant if it dosent work for ftp, but it does for smb!


----------



## profx (Jun 8, 2003)

and yet another side note...

for ftp you will need a file named ".netrc" in your home directory with a line like this

```
machine xxx.xxx.xxx.xxx login USER password PASSWORD
```

replace xxx.xxx.xxx.xxx with the ftp server ip, USER with your username and PASSWORD with... i leave you to figure that one out!

works for me!!


----------

