Page 1 of 1

Embedded shell script fails

PostPosted: Wed Apr 27, 2011 9:40 am
by brijazz
I have a shell script (in /usr/local/bin) called 'mkvdts2ac3', whose function is to convert audio inside of MKV files. When I invoke it from a Terminal command, it works flawlessly. However, I can't get Hazel to invoke it.

In Hazel, I'm using 'Run Shell Script -> Embedded Script'. I'm using this argument, using /bin/sh:

Code: Select all
mkvdts2ac3 "$1"

This returns "Error processing shell script on file ...". I also tried a couple of other variations, such as:

mkvdts2ac3 $1 (no quotes around the file reference)
mkvdts2ac3 "$1" (with /bin/bash this time)
mkvdts2ac3 $1 (again, with /bin/bash)

I'm running Hazel 2.3.8 on OS X 10.6.7. Any advice on getting this to work?

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 2:45 pm
by Mr_Noodle
Can you post the error from the logs? The only thing I can tell by looking at it now is that you may need to specify the full path for the mkvdts2ac3 program.

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 3:15 pm
by brijazz
Mr_Noodle wrote:Can you post the error from the logs? The only thing I can tell by looking at it now is that you may need to specify the full path for the mkvdts2ac3 program.


From ~/Library/Logs/Hazel/Hazel.log (with my username removed for privacy):
Code: Select all
2011-04-27 15:25:13.759 (null)[0] nsa-sample.mkv: Rule MKV - DTS2AC3 matched.
2011-04-27 15:25:13.829 hazelfolderwatch[1213] [Error] Shell script failed: Error processing shell script on file /Users/xxxxxx/MKVs/nsa-sample.mkv.


From ~/Library/Application Support/Hazel/xxxxx.hazeldb:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Contents</key>
   <dict>
      <key>.DS_Store</key>
      <dict>
         <key>Date Added</key>
         <date>2011-04-27T19:11:57Z</date>
         <key>File ID</key>
         <string>4583833</string>
      </dict>
      <key>nsa-sample.mkv</key>
      <dict>
         <key>Date Added</key>
         <date>2011-04-27T19:11:57Z</date>
         <key>File ID</key>
         <string>4559487</string>
         <key>Last Error Time</key>
         <date>2011-04-27T19:12:24Z</date>
         <key>Rule Signature</key>
         <string>{extension LIKE[cd] "mkv" AND labelColor ==[cd] 1}:{(shellscript:/bin/sh:54090b43e9143979813d0952d439b36c,{
})}</string>
      </dict>
   </dict>
   <key>File Map</key>
   <dict>
      <key>4559487</key>
      <dict>
         <key>Name</key>
         <string>nsa-sample.mkv</string>
      </dict>
      <key>4583833</key>
      <dict>
         <key>Name</key>
         <string>.DS_Store</string>
      </dict>
   </dict>
   <key>Version</key>
   <integer>3</integer>
</dict>
</plist>

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 3:28 pm
by Mr_Noodle
Sorry, should have been more specific. Go to the "Info" section and click on "View Log". Search for the file in question. If there was an error, it should hopefully give more information on the nature of the error.

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 3:42 pm
by brijazz
Here's what I've got from the hazel.log file:

Code: Select all
2011-04-27 15:41:59.959 (null)[0] nsa-sample.mkv: Rule MKV - DTS2AC3 matched.
/var/folders/VC/VCBr+5fBGyKzdlt6H7bPzU+++TI/-Tmp-/hazelfolderwatch-1531: line 1: mkvdts2ac3: command not found
2011-04-27 15:42:00.030 hazelfolderwatch[1531] [Error] Shell script failed: Error processing shell script on file /Users/xxx/MKVs/nsa-sample.mkv.


I removed my username for privacy reasons :)

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 3:50 pm
by Mr_Noodle
So, my first guess seemed to be right. You need to specify the full path to the program. Hopefully, that should fix it.

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 3:56 pm
by brijazz
Mr_Noodle wrote:So, my first guess seemed to be right. You need to specify the full path to the program. Hopefully, that should fix it.


OK... how do I go about doing that? I just tried putting /usr/local/bin mkvdts2ac3 "$1", but that failed too.

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 4:29 pm
by Mr_Noodle
Try:
Code: Select all
/usr/local/bin/mkvdts2ac3 "$1"

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 4:37 pm
by brijazz
Still a no-go. What should I be putting as the shell?

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 4:39 pm
by Mr_Noodle
Is the program actually in /usr/local/bin? What's the error in the log this time?

Maybe you should post a screenshot of your script.

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 5:01 pm
by brijazz
Here's what's in the hazel.log:

Code: Select all
2011-04-27 16:53:12.527 (null)[0] nsa-sample.mkv: Rule MKV - DTS2AC3 matched.
2011-04-27 16:53:12.721 hazelfolderwatch[2801] [Error] Shell script failed: Error processing shell script on file /Users/briancashion/MKVs/nsa-sample.mkv.


The program is definitely in /usr/local/bin. Here's the output of "type mkvdts2ac3", as executed in Terminal:

Code: Select all
mkvdts2ac3 is /usr/local/bin/mkvdts2ac3


Here's the screenshot:
Image

And for good measure, a Finder screenshot showing the mkvdts2ac3 command:
Image

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 5:04 pm
by Mr_Noodle
I think at this point you should email me. In the "Info" section, click on the "Contact Support" link. Attach the program and a sample file which it fails on. I'll see if I can replicate it here.

Re: Embedded shell script fails

PostPosted: Wed Apr 27, 2011 5:12 pm
by brijazz
E-mail sent.

Re: Embedded shell script fails

PostPosted: Sun Jan 27, 2013 12:15 pm
by a_freyer
I have solved this exact problem offline with another user. See our solution here. (EDIT - only nine months late...)