Hello, does anybody know about how to "send" a command or a text line from R to another program? I have written a script in which several calculations are made and outputfiles (csv) are generated. Afterwards I open another program (Fortran) via shell.exec. This program asks for the names if the output files and it would be quite practically if it could just adopt the file names from the r script. Thank you in advance! ----- Tamara Hoebinger University of Vienna -- View this message in context: http://www.nabble.com/send-command-to-other-program-tp23284885p23284885.html Sent from the R help mailing list archive at Nabble.com.
Does ?system help? Ranjan On Tue, 28 Apr 2009 13:00:28 -0700 (PDT) thoeb <t.hoebinger at gmail.com> wrote:> > Hello, > does anybody know about how to "send" a command or a text line from R to > another program? I have written a script in which several calculations are > made and outputfiles (csv) are generated. Afterwards I open another program > (Fortran) via shell.exec. This program asks for the names if the output > files and it would be quite practically if it could just adopt the file > names from the r script. > > Thank you in advance! > > ----- > Tamara Hoebinger > University of Vienna > -- > View this message in context: http://www.nabble.com/send-command-to-other-program-tp23284885p23284885.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
Thanks! I have not used "system" before. May it works if "command" ist the call for the program, but how can I integrate the transfer of the file names (strings) from R to the program? Ranjan Maitra wrote:> > Does ?system help? > > Ranjan > > On Tue, 28 Apr 2009 13:00:28 -0700 (PDT) thoeb <t.hoebinger at gmail.com> > wrote: > >> >> Hello, >> does anybody know about how to "send" a command or a text line from R to >> another program? I have written a script in which several calculations >> are >> made and outputfiles (csv) are generated. Afterwards I open another >> program >> (Fortran) via shell.exec. This program asks for the names if the output >> files and it would be quite practically if it could just adopt the file >> names from the r script. >> >> Thank you in advance! >> >> ----- >> Tamara Hoebinger >> University of Vienna >> -- >> View this message in context: >> http://www.nabble.com/send-command-to-other-program-tp23284885p23284885.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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. >> > > ______________________________________________ > 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. > >----- Tamara Hoebinger University of Vienna -- View this message in context: http://www.nabble.com/send-command-to-other-program-tp23284885p23290927.html Sent from the R help mailing list archive at Nabble.com.
thoeb wrote:> Hello, > does anybody know about how to "send" a command or a text line from R to > another program? I have written a script in which several calculations are > made and outputfiles (csv) are generated. Afterwards I open another program > (Fortran) via shell.exec. This program asks for the names if the output > files and it would be quite practically if it could just adopt the file > names from the r script. >Hi Tamara, If the succeeding program can read the name of the input file via the command line arguments, like: myfortranprogram -i myfile.csv you can include the arguments in the shell call. Alternatively, you could have R write a shell script that would execute the program with the appropriate arguments, then call the shell script from R. Of course if your program has to have keyboard input for the filename, you would have to resort to magic like writing the filename into the keystroke buffer. Jim
Hi, Consider also that you may easily modify system names from inside your R script as: system("mv oldname newname") Best Regards, Javier ...> thoeb wrote: >> Hello, >> does anybody know about how to "send" a command or a text line from R to >> another program? I have written a script in which several calculations >> are >> made and outputfiles (csv) are generated. Afterwards I open another >> program >> (Fortran) via shell.exec. This program asks for the names if the output >> files and it would be quite practically if it could just adopt the file >> names from the r script. >> > Hi Tamara, > If the succeeding program can read the name of the input file via the > command line arguments, like: > > myfortranprogram -i myfile.csv > > you can include the arguments in the shell call. Alternatively, you > could have R write a shell script that would execute the program with > the appropriate arguments, then call the shell script from R. Of course > if your program has to have keyboard input for the filename, you would > have to resort to magic like writing the filename into the keystroke > buffer. > > Jim > > ______________________________________________ > 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. >