Skip to main content

Hello,



I am trying to deploy a script that will ask users if they've filled out and submitted their time sheet. If they click Yes, the message goes away. If they click No, it launches Safari and brings it to the front.



I can get it to run on my machine just fine, but when I try to deploy it via Casper Remote or a policy, I get an error saying that "<" is an invalid character. In the very short script, I've quadruple checked, and can't find a < character at all. Can anyone offer any help as to what's going on?



For reference, here's the script (website it goes to has been changed for privacy):



display dialog "Have you completed your timesheet?" buttons {"Yes", "No"} default button 2
if the button returned of the result is "No" then
tell application "Safari" to open location "http://google.com/"
tell application "Safari"
activate
end tell
else
null
end if


If anyone has any tips as to what I can do to make this work, I'd greatly appreciate it!

You could just use jamfhelper for this!!



Can give you a hand on writing this if you need it :)


To add to this, would be cool to create this website as an app with fluid and then have it open the app on launch.


Cheers mate hope this helps



#!/bin/sh
jamfcheck="/usr/sbin/jamf"
# now check if it exists
if [[ -e $jamfcheck ]]
then
/bin/echo "JAMF binary present, continuing as planned..."
else
/bin/echo "JAMF binary is not present, we need to halt"
exit 55
fi
#edit your message here and add your icon here
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "/icons/timesheet.png" -heading "TimeSheet" -description "Have you completed your timesheet?" -button1 "No" -button2 "Yes" -defaultButton 1 -cancelButton 2

if [ $? -eq 0 ]
then
#open your location here or even create your own web app with Fluid and have that open here.
open "http://google.com/"
else
#If they filled it out another thanks you message....
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -heading "Thank You" -description "Remember, it is important that you fill out your timesheet" -button1 "OK" &
exit 0
fi

Sweet scrip to annoy all the late time sheet users!


I use the same script to remind the teachers that they should update, just have a smart list if there is more then 5 updates available to run software update via self service. They love me


Hello and many thanks for the script, very useful!
Just a question:
Is there a reason why it works perfectly here on 10.6 clients with (AD) network accounts while - for Macs with 10.7/10.8 - it only works wihile being logged as the local admin and it apparently stops after opening the first window with network accounts (clicking "yes/no" does nothing)?



I tried both with a scheduled policy and from Casper Remote and would think it's because of some security reason/script run as logged in user.



Thank you again!
Carlo



Running script Reminder_Timesheet.sh...
Script exit code: 1
Script result: JAMF binary present, continuing as planned...
LSOpenURLsWithRole() failed with error -10810 for the URL http://timesheet.html


Just put a sudo in front of the jamfHelper line, that should work then since it would be run as root and not the user



sudo /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "/icons/timesheet.png" -heading "TimeSheet" -description "Have you completed your timesheet?" -button1 "No" -button2 "Yes" -defaultButton 1  -cancelButton 2

Not even putting sudo worked...
I ended up scheduling a LaunchDaemon that calls the below Applescript (saved as app copied to the clients), as this too gave me the same error if called by a policy...



Thanks for the suggestion!
Ciao
Carlo



try
set the IP_address to "put the IP of your timesheet server"
do shell script ("ping -c 2 " & IP_address)
activate
display dialog "Have you completed your timesheet?" buttons {"Yes", "No"} default button 2
if the button returned of the result is "No" then
tell application "Safari" to open location "http://Timesheet.html"
tell application "Safari"
activate
end tell
else
display dialog "Thank you for your cooperation" & return & return & ¬
"Remember, it is important that you fill out your timesheet." buttons {"OK"} default button 1
end if
on error
quit script
end try

run it as a launch agent. that runs as the user, launch daemons run as root, and applescript is less than convenient to run as root because of security enhancements


I've posted this before, but here you go again. It is a proof of concept, to run an apple script from bash and have user interaction. You can also always use jamfhelper as well. All you would need to do is change the manual triggers at the bottom of the if/then logic.



#!/bin/bash

# proof of concept AppleScript interaction to end user in bash

theAnswer=$(/usr/bin/osascript <<AppleScript
tell application "Finder"
activate
display dialog "Do you want to know the meaning of the universe?" buttons {"No","Yes"} default button 2
if the button returned of the result is "No" then
set theAnswer to No
end if
end tell
AppleScript)

/bin/echo "${theAnswer}"

if [[ ${theAnswer} == "no" ]]

then /bin/echo "They obviously have read the Hitcherhiker's Guide and know it is 42"
else /bin/echo "The Answer is 42"
fi

exit 0


Just test before you deploy.



Thanks,
Tom


Cheers mate hope this helps



#!/bin/sh
jamfcheck="/usr/sbin/jamf"
# now check if it exists
if [[ -e $jamfcheck ]]
then
/bin/echo "JAMF binary present, continuing as planned..."
else
/bin/echo "JAMF binary is not present, we need to halt"
exit 55
fi
#edit your message here and add your icon here
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "/icons/timesheet.png" -heading "TimeSheet" -description "Have you completed your timesheet?" -button1 "No" -button2 "Yes" -defaultButton 1 -cancelButton 2

if [ $? -eq 0 ]
then
#open your location here or even create your own web app with Fluid and have that open here.
open "http://google.com/"
else
#If they filled it out another thanks you message....
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -heading "Thank You" -description "Remember, it is important that you fill out your timesheet" -button1 "OK" &
exit 0
fi


Have you tested this script in Ventura?


Reply