Hi

you should separate your commands with ; not \n and give them as an
argument of bash -c option.
The following command works for me:

    system("bash -c 'echo $0; echo $PATH' ")

Anne


On Sun, Jul 6, 2014 at 8:02 AM, Marc Girondot <marc_grt@yahoo.fr> wrote:

> Hi,
>
> I try to automatize some commands normally used in terminal that I would
> like to run in R.
>
> However, the same command xxx in terminal and in system("xxx") does not
> produce the same result.
>
> It seems related to the shell used and the variables of the shell.
>
> For example, in terminal:
> Marc-Girondot-MBA:Chlorophyle marc$ echo $PATH
> /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/
> local/sbin:/usr/local/ncl-6.2.0/bin:/opt/local/bin:/opt/
> local/sbin:/Library/Frameworks/GDAL.framework/Programs:/usr/bin:/bin:/usr/
> sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin
>
> whereas in R:
> > system("echo $PATH")
> /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/
> usr/texbin:/opt/local/bin
>
> The shell used in terminal is
> Marc-Girondot-MBA:Chlorophyle marc$ echo $SHELL
> /bin/bash
> Marc-Girondot-MBA:Chlorophyle marc$ echo $0
> -bash
>
> whereas in R, it is sh:
> > system("echo $0")
> sh
>
> And this sh does not read my configuration files. I have tried to modifiy
> the ~/.profile or ~/.login but system("echo $PATH") does not change.
>
> My question is then:
> is it possible to change the default shell used by system ? I have tried:
> system("/bin/bash\necho $0\necho $PATH")
>
> but R becomes unresponsive...
>
> or where is the configuration file for sh run by R ?
>
> Thanks a lot
>
> Marc
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>

	[[alternative HTML version deleted]]

