Skip to main content

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"

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'

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


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?


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.


#!/bin/sh

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

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


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


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.


Reply