[R] Calling R in BATCH mode from C programm

About this list Date view Thread view Subject view Author view Attachment view

From: alkatz@post.tau.ac.il
Date: Wed 21 May 2003 - 01:29:41 EST


Message-id: <1053444581.3eca49e59d052@webmail.tau.ac.il>

Hello R-people,

I have the following problem :

In order to run R script from DOS prompt in BATCH mode and pass it some
parameters I do the following :

Rterm --slave --no-save --no-restore <args.R> args.out ARG1=1 ARG2=2

It works fine :
the result is that the script args.R is isexecuted. Sys.getenv() sees the
arguments ARG1 and ARG2, and the R creates output file args.out

Now I want to be able to call the same command from C application :

#include <conio.h>
#include <process.h>
#include <string.h>

void main()
{
   char *args[10], prog[80];
   int ch;

   strcpy(prog, "C:\\Program Files\\R\\RBase\\bin\\Rterm.exe ");

   /* Arguments to Rterm.exe */
   args[0] = "--slave";
   args[1] = "--no-save";
   args[2] = "--no-restore";
   args[3] = "<args.R>";
   args[4] = "args.out";
   args[5] = "ARG1=1";
   args[6] = "ARG2=2";
   args[7] = NULL;
   

   _execl( prog, args[0], args[1], args[2], args[3], args[4], args[5], args[6],
NULL);
}

Rterm starts, but writes to output :

ARGUMENT '<args.R>' __ignored__
ARGUMENT 'args.out' __ignored__

Command Sys.getenv("ARG1") returns correct result => R sees the rest of the
arguments.

I tryed to type args[3] = "args.R" - without <> it does not help.

Does enyone know what might be my problem ??

Thanks,
Alex.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:50 EST