[R] Problem with system() and source on linux

Jeff Newmiller jdnewmil @ending from dcn@d@vi@@c@@u@
Thu Dec 20 16:13:06 CET 2018

Read the man page for bash... source is built-in to the shell interpreter. You should invoke a single shell instance that first sources the profile and then executes the program... but this has nothing to do with R... this would be true for any program invoking an external program on a POSIX-compatible operating system (i.e. not Windows), and so is OT here.

On December 20, 2018 3:00:04 AM PST, Agustin Lobo <aloboaleu using gmail.com> wrote:
>I quite often use system() to run other programs from within R, but
>have just hitted
>a problem:
>For a given program, I need to set up its environment, which I normally
>do with
>source /home/alobo/OTB-6.6.0-Linux64/otbenv.profile
>from the terminal.
>Now, when I try to do the same from within R, I get:
>> system("source /home/alobo/OTB-6.6.0-Linux64/otbenv.profile",
>sh: 1: source: not found
>Error in system("source /home/alobo/OTB-6.6.0-Linux64/otbenv.profile", 
>  error in running command
>I need this command to set the environment before I actually run the
>program. My idea was saving a simple script from within R  in which
>the first line would be
>source /home/alobo/OTB-6.6.0-Linux64/otbenv.profile
>and then run the script with system(), but I get that odd error with
>source. I thought source was just
>a plain linux command, how can it be "not found" from within system()?
>Any help much appreciated,

Sent from my phone. Please excuse my brevity.

More information about the R-help mailing list