Scripters,
I am trying to write a script to monitor print jobs, however I can’t seem to find my way out of this infinite loop. My code works great, only the app created from this scriprt won’t quit without being forced. I know what I am doing wrong, but I can’t seem to figure out how to fix it! This script scrapes the last line of the CUPS page log every second, and if there is a change, opens a dialog, and launches FF to a specific URL. TIA for any help.
-- begin variable declaration
-- begin user editable variables
-- message - the message you want the dialog box to display
set message to "Your print job has been added to your queue. Firefox will now open to a page where you can release this print job. If this is the first time you are seeing this dialog this session, you will be required to log in using your Novell login."
-- targetURL - the URL you want the user to be durected to upon completion of the print job
set targetURL to "123.123.123.123:8008/AuthJobs"
-- end user editable variables
-- end variable declaration
repeat
-- set intial values of polling variables
set old_entry to do shell script "sed '$!d' /var/log/cups/page_log"
set new_entry to do shell script "sed '$!d' /var/log/cups/page_log"
-- loop while there are no changes in the cups page log
repeat while old_entry is equal to new_entry
delay 1
set new_entry to do shell script "sed '$!d' /var/log/cups/page_log"
end repeat
-- display the dialog and open Firefox with the target URL
tell application "Finder"
activate
display dialog message buttons "OK" with icon 1
end tell
tell application "Firefox"
activate
OpenURL targetURL
end tell
end repeat