Posted on 12-28-2011 11:15 AM
Here is what i am trying to accomplish....i want the user to be able to click in self service and get user info such as what groups they are members of, their network home location etc.
the users exist in Active Directory so i used the dscl command to dump all user data for the console user to a tmp text file and then grep for the lines i want to use....that is all working! the problem lies in displaying the info in the GUI.
problem #1: the "jamf displayMessage" command seems to draw a message box of a fixed size, so if the user is a member of several groups they get cut off.
so...i used the applsescript "dislay dialoge" command. Problem solved.....until....
problem #2: the path to the users home directory from AD contains backslashes, one of which is followed by the letter "n" which applescript interprets as a new line command.
any ideas how to get AppleScript to ignore this, or a different way to output all this info to the screen?
thanks!
Posted on 12-29-2011 10:24 AM
With jamf displayMessage the box does increase, but possibly to a maximum size! Running 8.31. I guess you are trying to write more than this to your display box; I get 17 lines.
With respect to , try:
display dialog " o return"
the first slash will escape the second slash forcing it to be read as text.
Unix normally works with forward slashes not backward slashes, that's a windows thing. If you use:
su [username] -c printenv
Then you can get a full list of the users environment, including their home account
su [username] -c printenv | grep HOME | cut -d "=" -f 2
but with the bonus of forward slashes.
So you could have something like:
tell application "Terminal"
set myPath to (do shell script "su " & myUser & " -c printenv | grep HOME | cut -d "=" -f 2")
end tell
display dialog myPath
You'll need to set your variable for myUser
You could do text manipulation in AppleScript, but personally I find it quite boring and much prefer bash. I don't know what other information you are providing, but this would work for home and groups:
tell application "Terminal"
set myPath to (do shell script "id -Gn sholden | tr " " "
"")
set myHome to (do shell script "su " & myUser & " -c printenv | grep HOME | cut -d "=" -f 2")
end tell
display dialog myHome & return & myPath
Sean
Posted on 12-29-2011 10:46 AM
Have a look at this: http://macmule.com/2011/09/08/how-to-map-drives-printers-based-on-ad-group-membership-on-osx/
I wrote it to query AD group membership for the logged in user & also dealt with the slash issue.
Posted on 01-06-2012 10:45 AM
You actually don't need to tell the terminal to do anything, you can just use the 'do shell script' command by itself.