Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > - Connect to (-and mount) an AppleShare server via CLI

- Connect to (-and mount) an AppleShare server via CLI
Thread Tools
Dedicated MacNNer
Join Date: Mar 2001
Location: not far from my GSM phone
Status: Offline
Reply With Quote
Jan 27, 2003, 02:12 AM
 
I wish to CRON the connection to an AS server each week (the server in question reboots automatically weekly, so I have to re-connect).
What command do I have to type to have my Mac connect and mount the server in the bg?
Thanx 4 help.
Greg
Lao_Tseu
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jan 27, 2003, 08:39 AM
 
To connect to an AFP server via the command line you use the command:

mount_afp "afp://[username:password]@rhost[:port]/volume" node

The [ ] indicate optional parameters. Volume is the name of the volume as shared on the server, and node is where the server should be mounted on the local machine. The command must be run as root as far as I know.

The problem with doing this that you will find is that although it will correctly mount the server and make it available through your filesystem, it won't cause it to be recreated on your desktop. You'd need to do something with Apple's Disk management framework, which as far as I know are not command line controllable, but I can't be sure they are not. Regardless, the Disk management frameworks may have a better way of mounting the disk, not calling mount_afp directly, but allowing it to call it by itself.

- proton
     
lapinos  (op)
Dedicated MacNNer
Join Date: Mar 2001
Location: not far from my GSM phone
Status: Offline
Reply With Quote
Jan 27, 2003, 08:43 AM
 
Originally posted by proton:
To connect to an AFP server via the command line you use the command:

mount_afp "afp://[usernameassword]@rhost[ort]/volume" node

The [ ] indicate optional parameters. Volume is the name of the volume as shared on the server, and node is where the server should be mounted on the local machine. The command must be run as root as far as I know.

The problem with doing this that you will find is that although it will correctly mount the server and make it available through your filesystem, it won't cause it to be recreated on your desktop. You'd need to do something with Apple's Disk management framework, which as far as I know are not command line controllable, but I can't be sure they are not. Regardless, the Disk management frameworks may have a better way of mounting the disk, not calling mount_afp directly, but allowing it to call it by itself.

- proton
Aliases allow to connect, mount and access network files. Is ther a way to do that via CLI?
Should I rther try an AppleScript?
greg
Lao_Tseu
     
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
Jan 27, 2003, 05:15 PM
 
Originally posted by lapinos:
Aliases allow to connect, mount and access network files. Is ther a way to do that via CLI?
Should I rther try an AppleScript?
greg
I don't think AppleScript will help even if it can do it - an AppleScript started by CRON will not be able to communicate with the Finder (or other UI stuff) since it has to be a childprocess of the process it is trying to communicate with.

BTW, the stuff above I picked up on these boards, and have never tried, so take it with a truckload of salt (or just try it).
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jan 28, 2003, 08:36 AM
 
Originally posted by lapinos:
Aliases allow to connect, mount and access network files. Is ther a way to do that via CLI?
Should I rther try an AppleScript?
greg
Well you can always attempt to open the alias via the open command. Just do open /path/to/alias/to/open. I'm not sure what would happen if it is run from cron, particularly if it isn't running as the same user as is logged in.

- proton
     
Fresh-Faced Recruit
Join Date: Feb 2001
Location: BC, Canada
Status: Offline
Reply With Quote
Jan 29, 2003, 06:06 PM
 
You could try using osascript at the command-line:

Code:
/usr/bin/osascript -e 'open location "afp://username:password@name.of.server/nameOfSharePoint"'
This will cause the sharepoint to mount in the finder. It will also be accessable at /Volumes/nameOfSharePoint
     
lapinos  (op)
Dedicated MacNNer
Join Date: Mar 2001
Location: not far from my GSM phone
Status: Offline
Reply With Quote
Jan 30, 2003, 01:59 AM
 
Originally posted by grahamb:
You could try using osascript at the command-line:

Code:
/usr/bin/osascript -e 'open location "afp://username:password@name.of.server/nameOfSharePoint"'
This will cause the sharepoint to mount in the finder. It will also be accessable at /Volumes/nameOfSharePoint
grahamb, that's exactly what I needed. Just tried it in Terminal and it works.
Thank you!
Greg
Lao_Tseu
     
lapinos  (op)
Dedicated MacNNer
Join Date: Mar 2001
Location: not far from my GSM phone
Status: Offline
Reply With Quote
Jul 2, 2003, 06:24 AM
 
Originally posted by grahamb:
You could try using osascript at the command-line:

Code:
/usr/bin/osascript -e 'open location "afp://username:password@name.of.server/nameOfSharePoint"'
This will cause the sharepoint to mount in the finder. It will also be accessable at /Volumes/nameOfSharePoint
This worked fine with a NT/afp server. Now I need to mount an OSX server share. With this command I cannot go beyond the use name screen. Is it possible to mount as guest directly?
thanx
Lao_Tseu
     
lapinos  (op)
Dedicated MacNNer
Join Date: Mar 2001
Location: not far from my GSM phone
Status: Offline
Reply With Quote
Jul 2, 2003, 07:43 AM
 
I found the Solution:
It is a mix of the existing syntax with what I found typing "man mount_afp"
The result is:

/usr/bin/osascript -e 'open location "afp://;AUTH=No%20USer%20Authent@serveraddress/mountpoint"'

yessss
Lao_Tseu
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:15 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2