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

2018-12-20 Thread Jeff Newmiller
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

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

2018-12-20 Thread Ivan Krylov
On Thu, 20 Dec 2018 12:00:04 +0100 Agustin Lobo wrote: > 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. The problem with this approach is that in Unix-like systems, child processes cannot

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

2018-12-20 Thread Sarah Goslee
Actually, here's another possibility: system('bash -c "source filename"') On Thu, Dec 20, 2018 at 10:13 AM Sarah Goslee wrote: > > Hi, > > I can tell you what the problem is: > > You're probably running bash at the terminal command line, as I am: > > [sarahg@localhost]$ echo $0 > bash > > but

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

2018-12-20 Thread William Dunlap via R-help
Isn't 'source' a csh (tcsh, etc.) command? The sh (bash, etc.) command is a period, but you probably will need to use sh constructs in the file (like VAR=value;exportVAR) instead of csh constructs (like setenv VAR value). Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Dec 20, 2018 at

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

2018-12-20 Thread Sarah Goslee
Hi, I can tell you what the problem is: You're probably running bash at the terminal command line, as I am: [sarahg@localhost]$ echo $0 bash but the R system function uses sh system("echo $0") sh The bash shell has a source command; the sh shell doesn't. See here for a possible solution:

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

2018-12-20 Thread Agustin Lobo
Hi! 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,