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

MacQueen, Don macqueen1 at llnl.gov
Tue Apr 17 01:26:06 CEST 2012


I believe that shell() was superceded by system(), quite a long time ago.

However, I get this:

> foo <- system('printenv',intern=TRUE) ; foo[grepl('SHELL',foo)]
[1] "SHELL=/bin/tcsh"       "XTERM_SHELL=/bin/tcsh"

And tcsh is my login shell, i.e., as specified for my account at the OS
level. To me, this implies that you should get bash by default if your
account is configured for bash, but I can't know for certain.

-Don



-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/16/12 12:05 PM, "Justin Haynes" <jtor14 at gmail.com> wrote:

>Thanks Jeff, but I'm running a python program that expects certain
>functionality that bash provides and sh doesn't...  I can just stop using
>github checkouts and use system packages though and fix this.
>
>I'm mostly wondering where the "shell" command went in base R... it sounds
>like it completely solves this issue but doesn't exist in my R
>
>
>
>
>On Mon, Apr 16, 2012 at 10:58 AM, Jeff Newmiller
><jdnewmil at dcn.davis.ca.us>wrote:
>
>> 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.htm
>>>l
>> )
>> >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.
>>
>>
>
>	[[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