login script troubleshooting

anickless
Contributor II

I have a really simple script that is suppose to run when the user logs into the computer to set the computer name. However even through the log file says it runs, it doesn't show up on the client machine.

I have tried jamf manage and jamf update but no go.

Any suggestions to get it working?

e1e4a43b188e4eca95d2e6a27d94e88e

7 REPLIES 7

BOBW
Contributor II

Would it be because it is running as root and the end user never sees the prompt? Make sure you are running as the logged in user.

I am using cocoadialog to do a similar thing but making sure it is running as the current logged in user. Not sure how you would do that in Apple Script but im sure you can google it

Look
Valued Contributor III

Applescript should display for the currently logged in user regardless.
I don't think you need to tell "System Events" either just go straight to the dialog

#!/bin/sh
assignment=$(osascript<<END
set assignment to the text returned of (display dialog "Please Enter Computer Name" default answer "")
END)
echo $assignment

BOBW
Contributor II

hmm, this is something I might have to look into if it always picks up current logged in user.

Look
Valued Contributor III

@BOBW That definitely how it behaves on a few Self Service policies I have.

anickless
Contributor II

Yeah @Look it should and had in the past when it was first introduced to me but now it is not working while it works in self-service it doesn't in login hooks.

Look
Valued Contributor III

@anickless I think that might be a function of 10.11 and 10.12, I had to adjust a few of my login scripts that used Applescript to activate a little later in the login process for them to work correctly (not dialogs but other functions), I think 10.12 especially has change the order or how long some of the login items take.
I generally divorce the contents of the script away and then have it wait for the finder to fully load before attempting the tasks.

anickless
Contributor II

Doing some testing and found out the issue is isolated to touch bar macbook pros. Still frustrated by how it is not hooking at login :(