Problems with User Input script when launched from self service

jeffpugh
New Contributor III

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?

5 REPLIES 5

mm2270
Legendary Contributor III

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.

jeffpugh
New Contributor III

!/bin/sh

# 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

jeffpugh
New Contributor III

If running as user is the fix how would I go about doing this?

mm2270
Legendary Contributor III

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.

bentoms
Esteemed Contributor
Esteemed Contributor

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