Page 1 of 1

Running a shell script

PostPosted: Mon Mar 18, 2013 6:13 pm
by chobhamonian
Hi...completely new to Hazel and having a nightmare running a shell script!

I've read as much as I can find about using full path names to commands etc and the fact that Hazel runs the command in a non-interactive terminal, but I can't get my command to run. I'm trying to get Hazel to run a "make HTML" command so that when any restructured text file in a directory is modified, my Sphinx Python documentation website gets rebuilt.

In I terminal window I do this...
Code: Select all
#cd Documents/sphinks_astun
make html


...and all works fine...the make command operates on a makefile in the sphinks_astun directory and all is fine.

In Hazel, I've set it to run an external shell script when any of the files are changed. I've altered the script to add full path names, so my shell script is like this...

Code: Select all
#!/bin/bash

#cd /Users/myname/Documents/sphinks_astun

/usr/bin/make html


When Hazel tries to process the rule though I just get "shell script exited with non-successful status code:2"

Any help would be appreciated. (new to Hazel and shell scripts!!)

Re: Running a shell script

PostPosted: Tue Mar 19, 2013 11:17 am
by a_freyer
Have you tried specifying the makefile with:

make -f myMakeFile

Re: Running a shell script

PostPosted: Tue Mar 19, 2013 12:01 pm
by chobhamonian
Hi , thanks for the response....I just adjusted my shell script to the following....but I'm still getting a shell script exit error message code 2??

Code: Select all
#!/bin/bash

#cd /Users/myname/Documents/sphinks_astun

/usr/bin/make  -f /Users/myname/Documents/sphinks_astun/Makefile html

Re: Running a shell script

PostPosted: Tue Mar 19, 2013 12:04 pm
by a_freyer
are you seeing any output in the Hazel log?

Re: Running a shell script

PostPosted: Tue Mar 19, 2013 12:16 pm
by chobhamonian
This is an extract from the log...

Code: Select all
2013-03-19 15:59:25.233 hazelworker[1138] snn_live_planning_app_capture.rst: Rule Rebuild Documentation Website matched.
2013-03-19 15:59:26.516 hazelworker[1138] [Error] Shell script failed: Error processing shell script /Users/jrrutter/Documents/sphinks_astun/hazelscript.sh on file /Users/jrrutter/Documents/sphinks_astun/snn_live_planning_app_capture.rst.
2013-03-19 15:59:26.516 hazelworker[1138] Shellscript exited with non-successful status code: 2
2013-03-19 15:59:26.546 hazelworker[1138] Done processing folder sphinks_astun

Re: Running a shell script

PostPosted: Tue Mar 19, 2013 12:19 pm
by a_freyer
and you did say that this script works fine executed from the terminal?

Re: Running a shell script

PostPosted: Tue Mar 19, 2013 12:25 pm
by chobhamonian
Yep, no probs at all...I just navigate to the directory containing the makefile and run make html and Sphinx rebuilds the html files from the unstructured text files.

Re: Running a shell script

PostPosted: Tue Mar 19, 2013 12:40 pm
by a_freyer
your problem is likely with sphinx. Determine if there are any paths or environment variables it relies on.