Arcath Posted December 11, 2009 Posted December 11, 2009 I have a script that mounts a couple of shares to the users desktop. I added it the default login hooks and it runs on ling the only problem is that it wont pickup the username properly. Ive tried 3 ways of getting the username: $USER regexing the output of users /usr/bin/logname the first 2 return nothing on login and the last one returns "root". from what i can tell the script runs as root, is there any way to pickup what the user had typed into the login box?
AIT Posted December 11, 2009 Posted December 11, 2009 I have a script that mounts a couple of shares to the users desktop. I added it the default login hooks and it runs on ling the only problem is that it wont pickup the username properly. Ive tried 3 ways of getting the username: $USER regexing the output of users /usr/bin/logname the first 2 return nothing on login and the last one returns "root". from what i can tell the script runs as root, is there any way to pickup what the user had typed into the login box? what script is tthis.. bat? vb? have u done %username%
Arcath Posted December 11, 2009 Author Posted December 11, 2009 Ruby or BASH or Apple Script i use all 3 in the script
localzuk Posted December 11, 2009 Posted December 11, 2009 (edited) How about this AppleScript snippet? set MyName to do shell script "whoami" Then you can just use the MyName variable. eg. set MyName to do shell script "whoami" display alert MyName Edited December 11, 2009 by localzuk
localzuk Posted December 11, 2009 Posted December 11, 2009 whoami returns root Ah, ok. It turns out that login hooks always run as root. The variable $1 returns the logging in user apparently? Mac OS X: Creating a login hook
Arcath Posted December 11, 2009 Author Posted December 11, 2009 Ah, ok. It turns out that login hooks always run as root. The variable $1 returns the logging in user apparently? Thanks, its passed as the first argument to the hook, so in ruby its "ARGV[0]"
Arcath Posted December 11, 2009 Author Posted December 11, 2009 Next issue with the same script it mounts a samba share when i test it but when running as a login hook it doesnt mount, it creates the directory no problem but mount_smbfs doesnt seem to work is there a log where i can find out why it fails?
localzuk Posted December 11, 2009 Posted December 11, 2009 Not sure which log you'd want, but there are a good number of logs in /var/log including a samba directory. You could also output the result of the command to a file yourself.
Arcath Posted December 11, 2009 Author Posted December 11, 2009 Ive put the output into a .txt file and its empty...
sted Posted December 11, 2009 Posted December 11, 2009 set MyName to do shell script "whoami" tell application "Finder" try mount volume "smb://server.domain.local/" & MyName & "$" do shell script "ln -s /Volumes/" & MyName & "$ ~/Desktop" end try try mount volume "smb://server.domain.loca/" & "resources$" do shell script "ln -s /Volumes/" & "resources$" & " ~/Desktop" end try try mount volume "smb://server.domain.loca/" & "multimedia$" do shell script "ln -s /Volumes/" & "resources$" & " ~/Desktop" end try end tell
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now