Embedded Applescript Error Runs fine outside of Hazel

I embedded the following script in a Hazel rule (conditions of which are just label color):
And it throws up the following error:
This script runs fine in applescript editor program.
The script is meant to kick of a batch encode movies workflow i downloaded. The reason for the script is because the encode workflow kicks on a handbrake encode and I dont want more than 2 instances of handbrake running at the same time.
I am a super applescript noob so not sure what could be wrong since it works in applescript editor. Is it the nested shell script?
- Code: Select all
set myString to do shell script " /bin/ps -ax"
set allWords to (every word of myString)
set wordcount to 0
repeat with i in my allWords
if i contains "HandBrakeCLI" then set wordcount to wordcount + 1
end repeat
if wordcount < 2 then
activate application "Batch_Encode_Movies"
else
error number -128
end if
And it throws up the following error:
- Code: Select all
2010-12-01 08:03:07.662 hazelfolderwatch[15472] [Error] AppleScript failed: Error executing AppleScript on file /Volumes/Hackintosh Companion/Movie Process/20.0 New AnyDVDHD Rips/You Don't Mess With The Zohan (2008).
2010-12-01 08:03:08.116 hazelfolderwatch[15472] AppleScript error: {
NSLocalizedDescription = "allWords of \U00abscript\U00bb doesn\U2019t understand the count message.";
NSLocalizedFailureReason = "allWords of \U00abscript\U00bb doesn\U2019t understand the count message.";
OSAScriptErrorAppAddressKey = <NSAppleEventDescriptor: 'psn '("hazelfolderwatch")>;
OSAScriptErrorAppNameKey = hazelfolderwatch;
OSAScriptErrorBriefMessageKey = "allWords of \U00abscript\U00bb doesn\U2019t understand the count message.";
OSAScriptErrorMessageKey = "allWords of \U00abscript\U00bb doesn\U2019t understand the count message.";
OSAScriptErrorNumberKey = -1708;
OSAScriptErrorOffendingObjectKey = <NSAppleEventDescriptor: 'obj '{ 'form':'usrp', 'want':'prop', 'seld':'utxt'("allWords"), 'from':'null'() }>;
OSAScriptErrorRangeKey = NSRange: {0, 0};
}
This script runs fine in applescript editor program.
The script is meant to kick of a batch encode movies workflow i downloaded. The reason for the script is because the encode workflow kicks on a handbrake encode and I dont want more than 2 instances of handbrake running at the same time.
I am a super applescript noob so not sure what could be wrong since it works in applescript editor. Is it the nested shell script?