Page 1 of 1
Change Modification/Access Time on Images and Then Move

Posted:
Wed Mar 11, 2015 12:38 am
by Zyniker
I am attempting to use Hazel to change the modification and access times on images placed into a particular folder and then to move those image to a new folder. Whenever the rule runs, I get an error in the logs saying that the shell script failed. Here is the shell script I am currently using:
- Code: Select all
touch -afm
The only check this rule makes is whether or not the file is an image. After the check and the command, it should move the file to a new folder, but it never gets that far as the aforementioned command fails every time.
Re: Change Modification/Access Time on Images and Then Move

Posted:
Wed Mar 11, 2015 3:01 pm
by Mr_Noodle
There's no argument to the touch command. $1 is passed in as the file being matched so you want to use that. To be safe, enclose it in double quotes.
- Code: Select all
touch -afm "$1"
Re: Change Modification/Access Time on Images and Then Move

Posted:
Wed Mar 11, 2015 3:11 pm
by Zyniker
That's actually what I have for the shell script. This is the error it throws every time the rule is run:
- Code: Select all
hazelworker[43613] Shellscript exited with non-successful status code: 1
Re: Change Modification/Access Time on Images and Then Move

Posted:
Thu Mar 12, 2015 1:54 pm
by Mr_Noodle
Try debugging the script outside of Hazel.
Re: Change Modification/Access Time on Images and Then Move

Posted:
Fri Mar 13, 2015 1:48 am
by Zyniker
What you posted in your first reply is literally the entire script. There's nothing to debug.
Re: Change Modification/Access Time on Images and Then Move

Posted:
Fri Mar 13, 2015 11:17 am
by Mr_Noodle
So what happens when you run that script manually with the file it is failing on? Does it work or do you get an error?
Also, turn on debug mode as described in the sticky article at the top of this forum. That will show the output (though there may not be any in this case). Lastly, use the full path for the "touch" command to see if that changes anything.
Re: Change Modification/Access Time on Images and Then Move

Posted:
Tue Mar 17, 2015 3:59 am
by Zyniker
The command works precisely as expected when run outside of Hazel.
Re: Change Modification/Access Time on Images and Then Move

Posted:
Tue Mar 17, 2015 1:54 pm
by Mr_Noodle
How about the other things I suggested?
Re: Change Modification/Access Time on Images and Then Move

Posted:
Tue Mar 17, 2015 8:17 pm
by Zyniker
I've turned on debug mode. Here are the contents of the log file when I run the rule:
- Code: Select all
2015-03-17 17:15:23.021 hazelworker[89227] cloud.png: Rule Change Modification Date and Move to Optimize matched.
2015-03-17 17:15:23.021 hazelworker[89227] DEBUG: Manual run. Forcing actions to be executed.
2015-03-17 17:15:23.023 hazelworker[89227] Exception caught while executing shell script: Couldn't posix_spawn: error 13
2015-03-17 17:15:23.024 hazelworker[89227] [Error] Shell script failed: Error processing shell script on file /Users/ ... ImageOptim Staging/cloud.png.
2015-03-17 17:15:23.024 hazelworker[89227] Shellscript exited with non-successful status code: -900
2015-03-17 17:15:23.024 hazelworker[89227] DEBUG: Tapping error retry sequence
Re: Change Modification/Access Time on Images and Then Move

Posted:
Wed Mar 18, 2015 12:56 pm
by Mr_Noodle
What shell do you have listed in the shell field? Make sure that points to valid script interpreter.
Re: Change Modification/Access Time on Images and Then Move

Posted:
Wed Mar 18, 2015 3:07 pm
by Zyniker
It was using /usr/bin/false. I swapped it over to /usr/bin/true and now it appears to be working. Thanks for the help.
Re: Change Modification/Access Time on Images and Then Move

Posted:
Thu Mar 19, 2015 11:41 am
by Mr_Noodle
Err, that's not correct either. true always returns true and is not a real shell. You need to use something like /bin/sh.