Posted on 01-06-2016 02:29 PM
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
sudo -u $3 mkdir "/Volumes/common_share"
sudo -u $3 mount -t smbfs "//sydmsoppfs01/common_share" "/Volumes/common_share"
Posted on 01-06-2016 03:35 PM
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'
Posted on 01-06-2016 04:45 PM
is there a way to use a user than can overwrite it? or if it doesn't exist bypass it and open it?
Posted on 01-06-2016 05:04 PM
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?
Posted on 01-06-2016 05:11 PM
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.
Posted on 01-06-2016 05:28 PM
#!/bin/sh
if [ -d "/Volumes/common_share/" ]; then
open /Volumes/common_share
else
open 'smb://sydmsoppfs01/common_share'
fi
Posted on 01-06-2016 05:36 PM
thanks for that
can I just add that with the previous script I had?
Posted on 01-06-2016 05:42 PM
this is what i currently have and still doesn't work
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
Posted on 01-06-2016 05:45 PM
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.