Page 1 of 1

Shell script statement works in Terminal, fails in Hazel (2)

PostPosted: Fri Dec 30, 2016 7:25 am
by WorkflowsGuy
Again, I have a one-line bash script that works both on the command line and in Code Runner, but fails in Hazel.

It is simply a call to the utility convmv (installed through homebrew) that converts a filename from one charset to another and looks like this.

Code: Select all
convmv -i --notest -f utf8 -t iso-8859-1 "$1"


When putting this into a "Run shell script/embedded script" command and running the rule, in Activity MonItor I can see a "per5.16" process using 99.9 % CPU and the rule does not complete.

Adding and exporting variables for LANG and LC_CTYPE as per my related post (https://www.noodlesoft.com/forums/viewtopic.php?f=4&t=6682&p=19042&hilit=shell+script+fails#p19042) does not change anything.

What is necessary to make this work in Hazel?

Thanks!

Re: Shell script statement works in Terminal, fails in Hazel

PostPosted: Fri Dec 30, 2016 10:41 am
by Mr_Noodle
Use a full path to convmv. You can't assume the path is what you use in your interactive shell.

If you are still having problems, have the script print output. You can turn on debug mode in Hazel to view that output in the logs: https://www.noodlesoft.com/kb/hazel-debug-mode/

Re: Shell script statement works in Terminal, fails in Hazel

PostPosted: Fri Dec 30, 2016 1:48 pm
by WorkflowsGuy
Hello Mr. Noodle,

Use a full path to convmv. You can't assume the path is what you use in your interactive shell.

All the commands installed through Homebrew work in my shell scripts called from Hazel rules without needing a full path. But just to be sure, I added the full path in my script -> no improvement.

As I became aware only through this issue, convmv is a Perl script. So the command is found as the "stuck" Perl5.16 interpreter process shows.

I also added an echo "Test" as the first line in my shell script as you suggested, but the "Test" is not output in the Hazel debug log when the rule is executed. The shell script looks like this:

Code: Select all
echo "Test"
LC_CTYPE=UTF-8
export LC_CTYPE
convmv -i --notest -f utf8 -t iso-8859-1 "$1"

So the question is, what is different in the calling/execution process of Hazel->Bash shell script->Perl script that causes the Perl interpreter to get locked?

Re: Shell script statement works in Terminal, fails in Hazel

PostPosted: Mon Jan 02, 2017 12:40 pm
by Mr_Noodle
The output won't appear until the script finishes. As for why it's locked, I can't say. Try a simpler perl script to help isolate the issue.

Re: Shell script statement works in Terminal, fails in Hazel

PostPosted: Tue Jan 03, 2017 1:01 pm
by WorkflowsGuy
Turns out, it is not a good idea to call a command from Hazel with it's "interactive" option enabled... :roll: