mount share drive error message

FoxSports
New Contributor

Hi,

I'm trying to deploy a script to mount a share drive and getting the following:

Executing Policy test common share...
Running script test common share...
Script exit code: 1
Script result: mkdir: /Volumes/common_share: File exists
mount: realpath /Volumes/common_share: Permission denied

Script looks like this

!/bin/bash

sudo -u $3 mkdir "/Volumes/common_share"
sudo -u $3 mount -t smbfs "//sydmsoppfs01/common_share" "/Volumes/common_share"

8 REPLIES 8

hkabik
Valued Contributor

It looks like the folder common_share is already in Volumes, likely created by another account so the $3 user doesn't have access to overwrite or alter it. On the machine where you are getting that error, if you:

ls -l /Volumes

Does common_share show up? If so, who owns it?

You could of course greatly simplify things by using:

#!/bin/sh

open 'smb://sydmsoppfs01/common_share'

FoxSports
New Contributor

is there a way to use a user than can overwrite it? or if it doesn't exist bypass it and open it?

hkabik
Valued Contributor

Again:

open 'smb://sydmsoppfs01/common_share'

Will just flat out mount it regardless of if there is already a /Volumes/common_share folder. It will append a "-1" to it if common_share is already in /Volumes.

What exactly is the scenario here? Why is common_share already in /Volumes? Have you already mounted it at another point, if so why are you trying to mount it again? If it is already mounted do you want your script to bypass the mount command and perform some other task?

FoxSports
New Contributor

I am creating a script to map file shares to users macs upon log on.
In this case I am testing it on my mac which has that volume already created.
If its already there I would like to have it bypassed and opened.

hkabik
Valued Contributor
#!/bin/sh

if [ -d "/Volumes/common_share/" ]; then
    open /Volumes/common_share
else
    open 'smb://sydmsoppfs01/common_share'
fi

FoxSports
New Contributor

thanks for that
can I just add that with the previous script I had?

FoxSports
New Contributor

this is what i currently have and still doesn't work

!/bin/bash

sudo -u $3 mkdir "/Volumes/common_share"
sudo -u $3 mount -t smbfs "//sydmsoppfs01/common_share" "/Volumes/common_share"
if [ -d "/Volumes/common_share/" ]; then open /Volumes/common_share
else open 'smb://sydmsoppfs01/common_share''
fi

hkabik
Valued Contributor

This is the whole script:

#!/bin/sh

if [ -d "/Volumes/common_share/" ]; then
    open /Volumes/common_share
else
    open 'smb://sydmsoppfs01/common_share'
fi

Nothing else is needed. Try that, see if it does what you need. If it doesn't, I'm really not sure how else to help.