Shell scripts not working since 3.1

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

Moderator: Mr_Noodle

Shell scripts not working since 3.1 Wed Jun 19, 2013 4:34 pm • by maattt34
Hi,
I've just installed 3.1 and since then, all my shell scripts that used to work in 3.0.18 don't anymore :/
It seems that hazel doesn't wait for the script to end and directly pass on to the next action (Notifications). The log is absolutely normal and no errors are displayed, but the scripts simply don't do anything !

Tell me if you need more informations

Thank you ;)

Matthieu
maattt34
 
Posts: 3
Joined: Fri Jun 14, 2013 11:54 am

Re: Shell scripts not working since 3.1 Wed Jun 19, 2013 5:17 pm • by Mr_Noodle
Try turning on debug mode (see the sticky article up top). Script output is now logged in Hazel logs when debug mode is on so you can see what's happening there.

Note also that Hazel will now execute your default shell before executing your script. This was to make scripts in Hazel behave more like they do in Terminal.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Shell scripts not working since 3.1 Wed Jun 19, 2013 5:30 pm • by Mr_Noodle
Ok, it seems there may be an issue with scripts using sh. I suggest changing the shell to bash instead (which is the new default) as that seems to fix things.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Shell scripts not working since 3.1 Thu Jun 20, 2013 4:23 am • by jraduenz
Same problem here.

Mr Noodle, will you provide a fix for this?

No hurry, just asking before I have to adapt dozens of scripts.
jraduenz
 
Posts: 3
Joined: Mon Feb 06, 2012 6:28 am

Re: Shell scripts not working since 3.1 Thu Jun 20, 2013 7:13 am • by maattt34
Thank you Mr. Noodle, it works perfectly with bash. What an efficient support :)

Hazel rules!
maattt34
 
Posts: 3
Joined: Fri Jun 14, 2013 11:54 am

Re: Shell scripts not working since 3.1 Thu Jun 20, 2013 9:50 am • by Cassady
Oh no...

It took me months just to work out the previous script - and even then, I didn't actually do much, but relied heavily on people from different forums, to be get it set up correctly in (what I presume??) was shell...

Converting to bash? Easy?
Cassady
 
Posts: 47
Joined: Wed Mar 06, 2013 4:34 pm

Re: Shell scripts not working since 3.1 Thu Jun 20, 2013 10:10 am • by Cassady
Cassady wrote:Oh no...

It took me months just to work out the previous script - and even then, I didn't actually do much, but relied heavily on people from different forums, to be get it set up correctly in (what I presume??) was shell...

Converting to bash? Easy?



Mr. Noodle,

Further to the above - whereas I will take the time to figure all of the above out as soon as I have a moment - for now, were I to re-install the previous version of Hazel, off the .dmg, is there a possibility my scripts/rules will start working again?
Cassady
 
Posts: 47
Joined: Wed Mar 06, 2013 4:34 pm

Re: Shell scripts not working since 3.1 Thu Jun 20, 2013 10:13 am • by a_freyer
If you remove the shell script condition in the script and create a new shell script condition with the same content, your issue may be fixed.

I ran into a similar problem.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Shell scripts not working since 3.1 Thu Jun 20, 2013 12:51 pm • by Mr_Noodle
I'm working on a fix. Downgrading may be tricky because the rule format changed so I'd only recommend it if you have a backup of your rules readily available. Using bash should be a suitable workaround most of the time and since it's the new default shell, I'd recommend doing that anyways.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Shell scripts not working since 3.1 Thu Jun 20, 2013 2:50 pm • by Cassady
Appreciate the feedback. I'll see what I can sort out. The new upgrades look really useful, so that would be an absolute last resort!
Cassady
 
Posts: 47
Joined: Wed Mar 06, 2013 4:34 pm

Perl scripts also not working since 3.1 Thu Jun 20, 2013 6:59 pm • by xor2000
Also, my Perl scripts stopped working with Hazel 3.1.

They start with a hash bang like this:

Code: Select all
#!/opt/local/bin/perl


No logging output.

Code: Select all
#!/bin/bash


works.
xor2000
 
Posts: 13
Joined: Mon Oct 17, 2011 4:54 pm

Re: Shell scripts not working since 3.1 Fri Jun 21, 2013 10:54 am • by Mr_Noodle
I just posted 3.1.1 which should hopefully fix the shell script issues. Please report back here if it works for you or not.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Shell scripts not working since 3.1 Fri Jun 21, 2013 12:08 pm • by xor2000
Mr_Noodle wrote:I just posted 3.1.1 which should hopefully fix the shell script issues. Please report back here if it works for you or not.


Unfortunately, even with 3.1.1, my perl scripts starting with

Code: Select all
#!/opt/local/bin/perl


will still not run. The error message is:

Code: Select all
[Error] Shell script failed: Error processing shell script ...


I am not using an "embedded script" but am running the file.
xor2000
 
Posts: 13
Joined: Mon Oct 17, 2011 4:54 pm

Re: Shell scripts not working since 3.1 Fri Jun 21, 2013 12:25 pm • by Mr_Noodle
Turn on debug mode (see sticky article) and see what's logged then. Also, double check the script by running it outside Hazel.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Shell scripts not working since 3.1 Fri Jun 21, 2013 12:53 pm • by xor2000
Mr_Noodle wrote:Turn on debug mode (see sticky article) and see what's logged then. Also, double check the script by running it outside Hazel.


Here is a simple example script "test.pl" that I am calling from Hazel (please note that I am not using a rule embedded script):

Code: Select all
#!/opt/local/bin/perl

open(OUT, ">>/tmp/perl.log");
print OUT $ARGV[0] . "\n";
close(OUT);


It just logs that is has been called and the argument to "/tmp/perl.log".

No problem running it from the command line (using bash shell):

Code: Select all
mac:~/perl$ ./test.pl just_testing
mac:~/perl$ echo $?
0


From Hazel, the script won't even start, as I can see from the log file "/tmp/perl.log".

Before Hazel 3.1, I had no issues with scripts like this.

The Hazel debug log just states:

Code: Select all
2013-06-21 18:39:06.269 hazelworker[28129] [Error] Shell script failed: Error processing shell script /Volumes/Data/Users/xxx/perl/test.pl on file /Volumes/Data/Users/xxx/Ohne Titel.txt.
2013-06-21 18:39:06.269 hazelworker[28129] Shellscript exited with non-successful status code: 2
xor2000
 
Posts: 13
Joined: Mon Oct 17, 2011 4:54 pm

Next

Return to Support