[R] system command to a specific shell (bash)

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon Apr 16 19:58:22 CEST 2012


You could make a hash bang bash script that sources the file and then proceeds to do whatever you want. Bourne shell should have no problems invoking another shell.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Justin Haynes <jtor14 at gmail.com> wrote:

>I need to run a bash command, but when you call system() the default
>shell
>is sh (see my sessionInfo below).
>I found the shell command (
>http://www.stat.ucl.ac.be/ISdidactique/Rhelp/library/base/html/shell.html)
>but it seems to be disappeared in current versions of R?
>I am running all this from R CMD BATCH  with "system" calls to other R
>scripts.
>
>For a little more info, I'm generating sphinx documents (a python
>documentation library) through R and need to use a python virtual
>environment.
>So I need to call system('source bin/activate'), but "source" isn't a
>recognized command in the sh shell...
>
>
>Any help is appreciated,
>
>Justin
>
>> sessionInfo()
>R version 2.15.0 (2012-03-30)
>Platform: x86_64-pc-linux-gnu (64-bit)
>
>locale:
> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=C
>          LC_NAME=C
> [9] LC_ADDRESS=C               LC_TELEPHONE=C
>LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
>attached base packages:
>[1] graphics  grDevices utils     datasets  stats     grid      methods
>base
>
>other attached packages:
>[1] ggplot2_0.9.0  reshape2_1.2.1 plyr_1.7.1
>
>loaded via a namespace (and not attached):
>[1] colorspace_1.1-1   dichromat_1.2-4    digest_0.5.1      
>MASS_7.3-16
>     memoise_0.1        munsell_0.3
>[7] proto_0.3-9.2      RColorBrewer_1.0-5 scales_0.2.0      
>stringr_0.6
>     tools_2.15.0
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list