Mapping Another MAC Hard Drive Using Shell Script

Joined
Feb 12, 2019
Messages
5
Reaction score
0
Points
1
Your Mac's Specs
Mac Mini (Late 2014) 8GB 1600 MHz DDR3 memory 500GB internal, 2TB external running El Cap 10.11.6
I have 2 Mac Minis known as SystemB and SystemC. My question is that, using a shell script invoked by cron under Terminal, I would like to mount the hard disk of SystemB from SystemC. This is easy enough to do using Finder, but none of the mount commands I've tried in my shell script have worked.

On a different forum, I found someone using Sierra had done this with the "open" command. Since I'm at the highest release of El Cap before the release of Sierra, I tried the "open" command to see if it worked, and it did. Here is the (sanitized) command I'm currently using:

open 'smb://User:User&123@MAC-SYSTEMB/Desktop'

Originally the user password contained an "@" (i.e., "User@123"), but I simply could not escape this no matter what quoting or backslash options I tried, so I changed the "@" in the password to an "&", which works as long as I quote the "open" argument as shown.

Now, this is an OK solution, but it is not an ideal solution, because the "open" command above opens a Finder window when the "open" completes. This means that every time my "cron" script runs, it opens the Finder window on my desktop. I would really rather it didn't do that. So, I'm still open to suggestions on how to network-map the hard-drive on SystemB from SystemC. There doesn't seem to be a "nfsmount" or "netmount" command in the shell, and I don't see (or, perhaps, don't understand) how any of the options on "mount" would let me do this.
 
OP
3
Joined
Feb 12, 2019
Messages
5
Reaction score
0
Points
1
Your Mac's Specs
Mac Mini (Late 2014) 8GB 1600 MHz DDR3 memory 500GB internal, 2TB external running El Cap 10.11.6
Thanks, but no. I do not want SystemB's hard disk permanently mounted. I want to mount the disk upon demand, copy some files, then umount it. My cron script runs whether or not I'm logged in, but the above solution will only work WHEN I'm logged in. For example, if I restart the system without logging in, the cron script should still be able to do its job without requiring me to log in.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Why not use the 'mount_smbfs' wrapper if you are mounting a SMB file system.

You would use
Code:
sudo mount_smbfs //[COLOR=#333333]User:User&123@MAC-SYSTEMB/Desktop /Where/To/Mount[/COLOR]

This will require that you have already created /Where/To/Mount before and this also requires that you change permissions of that folder so that you can access it without using SUDO.
 
OP
3
Joined
Feb 12, 2019
Messages
5
Reaction score
0
Points
1
Your Mac's Specs
Mac Mini (Late 2014) 8GB 1600 MHz DDR3 memory 500GB internal, 2TB external running El Cap 10.11.6
Not having much luck with this.

I am logged in as "bill". I created a mount point called "mntpoint" within my home directory, and issued "chmod 777 mntpoint" against it. Thus, the specific mount point is "/User/bill/mntpoint":

MAC-SYSTEMC:~ bill$ ls -al | grep mntpoint
drwxrwxrwx 2 bill staff 68 Feb 12 11:23 mntpoint
MAC-SYSTEMC:~ bill$

But when I try the "mount_smbfs" command it fails thus:

MAC-SYSTEMC:~ bill$ sudo mount_smbfs '//User:User&123@MAC-SYSTEMB/Desktop' mntpoint
mount_smbfs: server rejected the connection: Authentication error
MAC-SYSTEMC:~ bill$

However, using the "open" command with exactly the same credentials for SYSTEMB, it works:

MAC-SYSTEMC:~ bill$ open 'smb://User:User&123@MAC-SYSTEMB/Desktop'
(Finder window opens to desktop on SYSTEMB).
MAC-SYSTEMC:~ bill$

So I don't understand why I'm getting an authentication error.

A couple of times, sudo asked for a password, but I couldn't remember whether it wanted my password or an admin password, so I entered mine. Now it doesn't ask for the password any more, it seems to remember and use the (wrong) one. I do know the admin password, and would try it if I could get sudo to ask for it. Quitting out of terminal altogether and starting a new terminal session doesn't seem to make any difference.
 
Joined
Dec 11, 2010
Messages
1,808
Reaction score
40
Points
48
Location
Chicago
Your Mac's Specs
late 2012 mini w/SSD
So, on the server, did you setup the "sharing" system prefs to include what you want shared, and click Options and include Samba in that? and, when you are connecting to the server, are you using a named account on the server and the password for the account on the server?
Your local client password isn't useful for mounting a server.
 
OP
3
Joined
Feb 12, 2019
Messages
5
Reaction score
0
Points
1
Your Mac's Specs
Mac Mini (Late 2014) 8GB 1600 MHz DDR3 memory 500GB internal, 2TB external running El Cap 10.11.6
Sorry to be so long getting back to you. Yes, SystemB is set up correctly as you described, and keep in mind that the "open" command functions correctly, while the mount command fails with exactly the same credentials.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top