Jump to content

Recommended Posts

Posted

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?

Posted
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%

Posted (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 by localzuk
Posted
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]"

Posted

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?

Posted

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.

Posted
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 

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...