I think that's my first true question (rather than answer) to R-help. As R has, for a long time, become my primary scripting and programming language, I'm prefering at times to write Rscript files instead of shell scripts, notably when R has nice ways to do some of the things. On a standard standalone platform with standard R, I would start such a script with --------------------------------------- #! /usr/bin/Rscript --vanilla --------------------------------------- (yes, the "--vanilla" is important to me, in this case) However; as, at work, my scripts have to work correctly on quite a few different (unixy : several flavors of Linux, Solaris, MacOS X) platforms, *and* as an R developer, I have many different versions of R installed simultaneously, using /usr/bin/Rscript is not an option. Rather, I'd use the /usr/bin/env trick : --------------------------------------- #! /usr/bin/env Rscript --------------------------------------- which finds Rscript in "the correct" place, according to the current PATH. All fine till now. PROBLEM: It does not work with '--vanilla' or any other argument: If I start my script with #! /usr/bin/env Rscript --vanilla the error message simply is /usr/bin/env: Rscript --vanilla: No such file or directory I have tried a few variations on the theme, using quotes in different places, but have not succeeded till now. Any suggestions? Martin Maechler, ETH Zurich
I guess you may try this http://modules.sourceforge.net/ I have seen a lot of clusters using this to manage software of different versions. Feng On 04/13/2012 10:32 AM, Martin Maechler wrote:> I think that's my first true question (rather than answer) > to R-help. > > As R has, for a long time, become my primary scripting and > programming language, I'm prefering at times to write Rscript > files instead of shell scripts, notably when R has nice ways to > do some of the things. > On a standard standalone platform with standard R, > I would start such a script with > --------------------------------------- > #! /usr/bin/Rscript --vanilla > --------------------------------------- > (yes, the "--vanilla" is important to me, in this case) > > However; as, at work, my scripts have to work correctly on quite a > few different (unixy : several flavors of Linux, Solaris, MacOS X) platforms, > *and* as an R developer, I have many different versions of R > installed simultaneously, using /usr/bin/Rscript is not an > option. > Rather, I'd use the /usr/bin/env trick : > > --------------------------------------- > #! /usr/bin/env Rscript > --------------------------------------- > > which finds Rscript in "the correct" place, according to the > current PATH. All fine till now. > > PROBLEM: It does not work with '--vanilla' or any other argument: > If I start my script with > #! /usr/bin/env Rscript --vanilla > the error message simply is > /usr/bin/env: Rscript --vanilla: No such file or directory > > I have tried a few variations on the theme, using quotes in > different places, but have not succeeded till now. > Any suggestions? > > Martin Maechler, ETH Zurich >-- Feng Li Department of Statistics Stockholm University SE-106 91 Stockholm, Sweden http://feng.li/
I guess you may try this http://modules.sourceforge.net/ I have seen a lot of clusters using this to manage software of different versions. Feng On 04/13/2012 10:32 AM, Martin Maechler wrote:> I think that's my first true question (rather than answer) > to R-help. > > As R has, for a long time, become my primary scripting and > programming language, I'm prefering at times to write Rscript > files instead of shell scripts, notably when R has nice ways to > do some of the things. > On a standard standalone platform with standard R, > I would start such a script with > --------------------------------------- > #! /usr/bin/Rscript --vanilla > --------------------------------------- > (yes, the "--vanilla" is important to me, in this case) > > However; as, at work, my scripts have to work correctly on quite a > few different (unixy : several flavors of Linux, Solaris, MacOS X) platforms, > *and* as an R developer, I have many different versions of R > installed simultaneously, using /usr/bin/Rscript is not an > option. > Rather, I'd use the /usr/bin/env trick : > > --------------------------------------- > #! /usr/bin/env Rscript > --------------------------------------- > > which finds Rscript in "the correct" place, according to the > current PATH. All fine till now. > > PROBLEM: It does not work with '--vanilla' or any other argument: > If I start my script with > #! /usr/bin/env Rscript --vanilla > the error message simply is > /usr/bin/env: Rscript --vanilla: No such file or directory > > I have tried a few variations on the theme, using quotes in > different places, but have not succeeded till now. > Any suggestions? > > Martin Maechler, ETH Zurich >-- Feng Li Department of Statistics Stockholm University SE-106 91 Stockholm, Sweden http://feng.li/
On 13 April 2012 at 10:32, Martin Maechler wrote: | I think that's my first true question (rather than answer) | to R-help. | | As R has, for a long time, become my primary scripting and | programming language, I'm prefering at times to write Rscript | files instead of shell scripts, notably when R has nice ways to | do some of the things. | On a standard standalone platform with standard R, | I would start such a script with | --------------------------------------- | #! /usr/bin/Rscript --vanilla | --------------------------------------- | (yes, the "--vanilla" is important to me, in this case) | | However; as, at work, my scripts have to work correctly on quite a | few different (unixy : several flavors of Linux, Solaris, MacOS X) platforms, | *and* as an R developer, I have many different versions of R | installed simultaneously, using /usr/bin/Rscript is not an | option. | Rather, I'd use the /usr/bin/env trick : | | --------------------------------------- | #! /usr/bin/env Rscript | --------------------------------------- | | which finds Rscript in "the correct" place, according to the | current PATH. All fine till now. | | PROBLEM: It does not work with '--vanilla' or any other argument: | If I start my script with | #! /usr/bin/env Rscript --vanilla | the error message simply is | /usr/bin/env: Rscript --vanilla: No such file or directory | | I have tried a few variations on the theme, using quotes in | different places, but have not succeeded till now. | Any suggestions? If moving away from Rscript to littler is an option: #!/usr/bin/r There is a well-known limitation for #! scripts which apparently reflect precisely one command-line argument. Because r uses getopt semantics, I *think* you can combine them as eg in #!/usr/bin/r -vti which would use --vanilla, --interactive and --rtemp toggle making sure we use temp files/dirs the way R does. However, it seems that --vanilla is now implicit as I can't get littler to read ~/.Rprofile. Somewhere between a feature and a bug :) Dirk -- R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL See agenda, registration details and more at http://www.RinFinance.com
On 13-04-2012, at 10:32, Martin Maechler wrote:> I think that's my first true question (rather than answer) > to R-help. > > As R has, for a long time, become my primary scripting and > programming language, I'm prefering at times to write Rscript > files instead of shell scripts, notably when R has nice ways to > do some of the things. > On a standard standalone platform with standard R, > I would start such a script with > --------------------------------------- > #! /usr/bin/Rscript --vanilla > --------------------------------------- > (yes, the "--vanilla" is important to me, in this case) > > However; as, at work, my scripts have to work correctly on quite a > few different (unixy : several flavors of Linux, Solaris, MacOS X) platforms, > *and* as an R developer, I have many different versions of R > installed simultaneously, using /usr/bin/Rscript is not an > option. > Rather, I'd use the /usr/bin/env trick : > > --------------------------------------- > #! /usr/bin/env Rscript > --------------------------------------- > > which finds Rscript in "the correct" place, according to the > current PATH. All fine till now. > > PROBLEM: It does not work with '--vanilla' or any other argument: > If I start my script with > #! /usr/bin/env Rscript --vanilla > the error message simply is > /usr/bin/env: Rscript --vanilla: No such file or directory > > I have tried a few variations on the theme, using quotes in > different places, but have not succeeded till now. > Any suggestions?I had similar problems running R scripts from BBEdit on Mac OS X. The problem could only be solved by making a shell script that uses the file extension to determine what to run. Searching internet yielded these pages which may be helpful: http://www.in-ulm.de/~mascheck/various/shebang/ http://stackoverflow.com/questions/4303128/how-to-use-multiple-arguments-with-a-shebang-i-e Berend