Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shebang line not working in R script

Tags:

r

shebang

ubuntu

I have the following script

#!/usr/bin/Rscript

print ("shebang works")

in a file called shebang.r. When I run it from command line using Rscript it works

$ Rscript shebang.r

but when I run it from the command line alone

$ shebang.r

It doesn't work. shebang.r command not found.

If I type (based on other examples I've seen)

$ ./shebang.r

I get permission denied.

Yes, Rscript is located in /usr/bin directory

like image 402
Milktrader Avatar asked Jun 27 '10 17:06

Milktrader


People also ask

Does shebang have to be first line?

The shebang is always on the first line of the file, and is composed of the characters #! followed by the path to the interpreter program. You can also specify command line options, if necessary.

What is -- vanilla in R?

(Here –vanilla is equivalent to –no-environ –no-site-file –no-init-file.) However, note that R CMD does not of itself use any R startup files (in particular, neither user nor site Renviron files), and all of the R processes run by these tools (except BATCH ) use –no-restore.

What is#!/ bin env?

As we mentioned earlier,#!/usr/bin/env bash is also a shebang line used in script files to execute commands with the Bash shell. It uses the env command to display the environment variables present in the system and then execute commands with the defined interpreter.


1 Answers

Make the file executable.

chmod 755 shebang.r
like image 113
Sjoerd Avatar answered Nov 14 '22 05:11

Sjoerd