Jump to content

Recommended Posts

Posted

I'm in the process of using launchd to launch a script at login which automounts students windows home shares to the desktop.

 

I am using the script which is available from the deploystudio wiki (deploystudio - OS X 10.5 Login Hooks), but I am consistently getting errors.

 

the jist of the code i'm using is...

 

## Set the $usrname variable

usrname=$(/usr/bin/id -P | awk -F: '{ print $1 }')

if [ $usrname != "admin" ]

then

if [ $usrname != "root" ]

then

mkdir /Users/$usrname/Desktop/"School Home"

mount_smbfs //$usrname@[server]/$usrname$ /Users/$usrname/Desktop/"School Home"

 

I have given up trying to get it working in the script as I am consistently getting the following error in the log...

 

mount_smbfs: mount error: /Users/[usrname]/Desktop/School Home: No such file or directory

 

I have started trying to simply get this working in the terminal replacing the variables with ones i know are correct, but get the same error consistently saying that the path doesn't exist!! But it blatently does!!!

 

Can anybody see what i'm doing wrong, or have had the same problem and solved it? I've spent the past 48 hours pulling my hair out!!

 

thanks,

 

Arron

Posted

I think it needs escaping:

 

mount_smbfs //$usrname@[server]/$usrname$ /Users/$usrname/Desktop/School\ Home

Alternatively, just leave out the space altogether - it will make life easier (I wish I could just disable the space bar for file and folder names :-))

Posted

I think i've just figured out what's wrong. The address to the share was incorrect, but the log file misled me into thinking something was wrong with the path.

 

Damn log files!!

 

Thanks for your help.

  • 6 months later...
Posted

I'm having some trouble understanding this script ... rather how to fill it out correctly if not doing it right below.

 

This is what I see from above:

## Set the $usrname variable
usrname=$(/usr/bin/id -P | awk -F: '{ print $1 }')
   if [ $usrname != "admin" ]
    then
       if [ $usrname != "root" ]
         then
           mkdir /Users/$usrname/Desktop/"H Drive"
           mount_smbfs //$usrname@Server_Name/$usrname$ /Users/$usrname/Desktop/"H Drive"
      fi
    fi
killall Terminal

 

Here is what I've get out of it for our site:

Set the $usrname variable
usrname=$(/usr/bin/id -P | awk -F: '{ print $1 }')
   if [ $usrname != "admin" ]
    then
       if [ $usrname != "root" ]
         then
           mkdir /Users/$usrname/Desktop/"H Drive"
           mount_smbfs //$usrname@SERVER/share$/$usrname$ /Users/$usrname/Desktop/"H Drive"
      fi
    fi
killall Terminal

 

where the following is the server & share path

SERVER/share$/

 

For testing I'm running "su /script path

I get prompted for a password, then get this error - "username" is not in the sudoers file.

 

Posted (edited)

@salinpoo

 

If I've understood you correctly why don't you use WorkGroup Manager to achieve this? You can specify a policy to auto-mount shares at a login time by installing WorkGroup Manager on a client workstation. Use Connect to Server from the Go Menu and try to use the IP Address of the Samba share as it tends to be more reliable. There are threads that have covered this already.

 

@Carter

 

If you need to issue a command or login to a shell using root you really should be using any one of these:

 

sudo -s

sudo su

sudo su -

 

My personal preference is "sudo -s" however it's your choice. You could refer to the relevant manual pages if you wish:

 

Loading…

Loading…

Loading…

 

All of Apple's Manual Pages for Server and Client OS are listed here:

 

Loading…

 

If you want a paper copy this command will create a pdf of a desired manual and save it to your desktop:

 

man -t binaryofyourchoice | pstopdf -i -o ~/Desktop/dscl.pdf

 

Where binaryofyourchoice could be sudo, su, dscl and so-on. If you want to see all the binaries (commands) installed simply launch Terminal and hold down the escape (esc) key. After a few seconds you should see "Display all xxxx possibilities? (y or n)." Simply type y and you'll see all the binaries listed. Depending on which OS you have the figure listed will be either more or less. Ironic that I end the previous sentence with more and less as these are two commands that are often used.

 

Antonio Rocco (ACSA)

Edited by AntonioRocco
Posted

Even running sudo this does not fix why i get the message error that it will not work. Am I not filling in the server info correctly.

 

Posted

Now just to confirm if I can get the share to mount I'm running the following

 

sudo -s mount_smbfs //$usrname@servername/home$/$usrname$

 

and I should be able to mount this from here should i not by hand by running in terminal?

 

I still get the error "username" is not in the sudoers file

 

Yet I can run from the "connect to server" option by putting in smb://servername/home$/username and it mounts without an issue

 

Posted

It sounds like the user you are running the command under is not allowed to run the sudo command. IE a standard AD networked account is not listed in the sudoers file.

 

I don't know how to remedy this as i never bothered looking. But have seen this several times myself, unless or course you know the user should be able to use sudo in which case I'm not sure. Running the command as a local admin should give the correct results.

Posted (edited)

Trying to look for something else I stumbled across this

 

Mac OS X v10.5, 10.6: Network home directory may not mount if bound to Active Directory

 

I was looking for the tickbox under directory services on 10.5 / 10.6 as you can check a box that will auto-magically mount the relevant users home area to the desktop although am not 100% sure if this is the same as what was suggested with ref to using workgroup manager on a client etc

 

The first link / article below has what I am reffering to ref this section

 

Exploring the “User Experience” Advanced Options Pane

 

http://ptgmedia.pearsoncmg.com/images/chap4_9780321635327/elementLinks/04-11.jpg

 

http://www.peachpit.com/articles/article.aspx?p=1431816

 

http://www.peachpit.com/articles/article.aspx?p=1431816&seqNum=2

Edited by mac_shinobi

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...