Posted on 06-06-2014 12:37 PM
I am using CocoaDialog and a script to ask for asset tag information. Script works fine as long as it isn't launched from Self Service. Launching from self service launches however the text box doesn't allow me to type anything in it. Any ideas?
Posted on 06-06-2014 12:43 PM
Post the script, or some relevant portion of it?
My first guess would be that you may need to run the cocoaDialog call as the user, not as the Casper service account/root. Common issue with these kinds of things.
Posted on 06-06-2014 01:04 PM
# Set CocoaDialog Location
CD="/usr/local/bin/cocoaDialog.app/Contents/MacOS/CocoaDialog"
# Dialog to enter the Asset Tag Information rv=($($CD standard-inputbox --title "L-Tag Importer" --no-newline --informative-text "Enter the L-Tag of the Company Owned System"))
ASSETTAG=${rv[1]}
# Set L-Tag using variable created above
/usr/sbin/jamf recon -assetTag $ASSETTAG
Posted on 06-06-2014 01:04 PM
If running as user is the fix how would I go about doing this?
Posted on 06-06-2014 01:23 PM
That might not be the issue after thinking about it further. You're saying the dialog appears but won't let you type into it? Doesn't sound like its not running as the user if so. If that was the issue it probably wouldn't even appear at all.
You might try throwing the --float flag into the CD command, as that makes it appear above all other windows. Maybe its not fully coming to the front, not sure. Based on the cocoaDialog executable name in your script, it looks like you're using the last stable release, and not the beta version? If so, the --float wasn't implied by default in that release. In one of the betas they made all CD windows float by default and you could flip that behavior by adding --no-float to the command.
Posted on 06-06-2014 03:45 PM
For a simple prompt like this, I'd use AppleScript.. this may work:
#!/bin/sh
ASSETTAG=$(osascript -e '
tell application "Finder"
display dialog "Enter the L-Tag of the Company Owned System" default answer ""
set ASSETTAG to the (text returned of the result)
end tell')
# Set L-Tag using variable created above
/usr/sbin/jamf recon -assetTag $ASSETTAG
# Exit
exit 0