Run shell script from iCloud drive

I have a data gathering setup that uses Hazel to run a shell script (that creates a plot of the data) every time a text file (containing the data) is detected as changed.
The shell script calls Rscript to run a R script to do the actual plotting and saving of the data. Both the shell script and the R script are located in the same folder as the data file.
The setup is in Dropbox folders, and works perfectly. However, I am investigating the possibility of moving it to iCloud drive. After copying the folder containing both the data and the scripts on iCloud drive, and modifying the rules to point at the new folder, I have issues.
The script runs fine on Terminal, but when run from Hazel i get an error:
The shell script is:
The R script references only the filename of the data file.
Adding the line:
just before the last line, the path printed matches what Hazel is displaying in the logs:
Any idea what am I doing wrong?
The shell script calls Rscript to run a R script to do the actual plotting and saving of the data. Both the shell script and the R script are located in the same folder as the data file.
The setup is in Dropbox folders, and works perfectly. However, I am investigating the possibility of moving it to iCloud drive. After copying the folder containing both the data and the scripts on iCloud drive, and modifying the rules to point at the new folder, I have issues.
The script runs fine on Terminal, but when run from Hazel i get an error:
- Code: Select all
2019-07-21 09:48:53.426 hazelworker[24042] Processing folder BCP
2019-07-21 09:48:55.689 hazelworker[24042] Battito_pressione.txt: Rule Copy of Esegui script - BCP matched.
2019-07-21 09:49:00.618 hazelworker[24042] [Error] Shell script failed: Error processing shell script /Users/andrea/Library/Mobile Documents/com~apple~CloudDocs/BCP/disegna_R.sh on file /Users/andrea/Library/Mobile Documents/com~apple~CloudDocs/BCP/Battito_pressione.txt.
2019-07-21 09:49:00.618 hazelworker[24042] Shellscript exited with non-successful status code: 2
2019-07-21 09:49:01.184 hazelworker[24042] Done processing folder BCP
The shell script is:
- Code: Select all
#!/bin/sh
cd `dirname $0`
/usr/local/bin/Rscript plot.R
The R script references only the filename of the data file.
Adding the line:
- Code: Select all
echo `pwd`
just before the last line, the path printed matches what Hazel is displaying in the logs:
- Code: Select all
/Users/andrea/Library/Mobile Documents/com~apple~CloudDocs/BCP
Any idea what am I doing wrong?