How to correctly use the embedded script option?

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

Moderator: Mr_Noodle

I've been using Hazel for a while but now doing some more complicated (for me) things.

I want to drop a CSV file in a folder, have it processed by an R script (which I have been using for years and is fine) which outputs an output file, and then the original input file is moved.

I have it working but I don't think it is the most efficient, as I am getting Hazel to rename the file before the script is called, and then the filename is hard coded. I can't get the filename to be passed from Hazel to R, and also can't see much info in the logs. I've read the user guide https://www.noodlesoft.com/manual/hazel/attributes-actions/using-shell-scripts/ but think I am missing something basic as I am not a terminal expert.

My shell is
Code: Select all
/usr/local/bin/Rscript

The first line of the code that works - hard coded
Code: Select all
data <- read.csv("~/Dropbox/testing\ related/input.csv", fileEncoding="latin1")

The code that doesn't work - trying to pass the path and file name
Code: Select all
data <- read.csv("$1", fileEncoding="latin1")

Any advice appreciated.
phrozenpenguin
 
Posts: 3
Joined: Fri Aug 25, 2017 7:35 pm

I don't know anything about Rscript but I'm guessing it has its own way of referring to arguments passed in. I'm guessing "$1" isn't it.
Mr_Noodle
Site Admin
 
Posts: 7162
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I have done some reading and experimenting with how Rscript expects things to be passed in, and you are right it was not how I was trying. However, I'm still having issues. Is there a way to see the actual error, or any output from the command line? The log just shows:

[Error] Shell script failed: Error processing shell script on file [path to csv].
hazelworker[33022] Shellscript exited with non-successful status code: 1
phrozenpenguin
 
Posts: 3
Joined: Fri Aug 25, 2017 7:35 pm

Turn on debug mode as described here: https://www.noodlesoft.com/kb/hazel-debug-mode/

That will show the output of the script in the logs.
Mr_Noodle
Site Admin
 
Posts: 7162
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Excellent, that was what I was looking for. Haven't had a chance to fix up yet, but hope to at some point.
phrozenpenguin
 
Posts: 3
Joined: Fri Aug 25, 2017 7:35 pm


Return to Support

cron