Shell script sandboxd when run with Hazel, not with Terminl?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hi, I'm a noob, so hope this isn't obvious, but I have searched and searched and found nothing similar online or on these forums.

I want to run tvnamer via Hazel:

IF:
<all> conditions met for <file or folder>
<kind> is <movie>
DO:
<run shell script><embedded script>:
usr/local/bin/tvnamer --batch "$1"

If I run this through terminal (with the folder location - Users/User/Downloads/DLTVShows/) it works flawlessly, but in Hazel, it never works. I added the 'usr/local/bin/' part to the shell command to try to make sure it wasn't an error in location.

Looking at the Hazel.log, the script is starting, matching the name of the tv shows, then reporting an error "processing shell script on file /Users/User/Downloads/DLTVShows/show.S01E09.avi", and that "shellscript exited with non-successful status code: 127"

I haven't had much luck tracking down that error code, but I think it might be a sandboxing issue somehow. I know Hazel isn't sandboxed, but in Console, I see a heap of "deny file-read-data /Users/User/Downloads/DLTVSHows" reports when I try to run the rule.

So, is part of the process being sandboxed when the script runs through Hazel, but not through terminal? Is that why I can't get this shell script working? Is there an alternative to run the script, through automator or something, that could help me bypass this hurdle?

Thanks!
rojonixon
 
Posts: 5
Joined: Mon Jan 07, 2013 3:33 pm

Sandboxd shouldn't assume control of any permissible file access, so despite the fact that you're seeing those errors, I doubt that sandboxd is causing the issue.

127 probably means that within the script that you're calling there is an executable being called that relies on path variables. As you already found out, Hazel requires exact paths - even WITHIN the script that you call externally. The shell is opened without the user profile within the directory of the file/folder called in Hazel.

I suggest opening that script to be sure that there are no unspecified paths.

Just to be sure that there isn't a permissions issue, I'd correct disk permissions.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Also, I'd suggest that you redirect all of this executable's logs to something a bit manageable/visible:

Code: Select all
usr/local/bin/tvnamer --batch "$1" &2>1 > /var/log/tvnamer.log
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Okay, looks like I figured out my own noob error.

I swear I tried it a hundred times this way, but after trialing and testing variations through an automator workflow, it worked. Tried it in Hazel, and it worked as well.

/usr/local/bin/tvnamer --batch /Users/User/Downloads/DLTVShows/
rojonixon
 
Posts: 5
Joined: Mon Jan 07, 2013 3:33 pm

Thanks for the response a_freyer! Will take the advice on board as I fumble my way through
rojonixon
 
Posts: 5
Joined: Mon Jan 07, 2013 3:33 pm

I guess your rule was matching a file?

For future reference, you could do this to make your script more portable within Hazel (i.e. diving into subfolders etc.)


Code: Select all
/usr/local/bin/tvnamer --batch "$(dirname "$1")"
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado


Return to Support