vokey588
vokey588

Reputation: 203

Executable R script with Mac OSX having problems

I'm trying to write a simple double-clickable file.command on my Mac OSX machine. Here is my shell script on the .command file:

 #!/usr/bin/env Rscript
 Rscript /Users/MyName/Dropbox/Workout_log_script/workout_log.R

And here is the error I get:

 MyName$ /Users/MyName/Desktop/workout_plotter.command ; exit;
 Error: object 'Rscript' not found
 Execution halted
 logout

I don't have much experience with using bash. Does anyone know how I can fix this? Thanks!

Upvotes: 0

Views: 2845

Answers (2)

damienfrancois
damienfrancois

Reputation: 59300

You are mixing two possible ways to do it:

either write a Bash script that launches the Rscript utility:

#!/bin/bash
Rscript /Users/MyName/Dropbox/Workout_log_script/workout_log.R

making sure Rscript is available from the $PATH and the Bash script is executable ; or

make the R script executable and add the so-called shebang

#!/usr/bin/env Rscript

at the first line of the R script. The R script will then be runnable by double clicking it.

Upvotes: 2

Denis Kohl
Denis Kohl

Reputation: 750

your interpreter string is not ok for bash use /usr/bin/Rscript

and make your script executable whit chmod 755 <script>

Upvotes: 1

Related Questions