Using a console application from within R

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using a console application from within R

Jonathan Weeks
I would like to open a console application from within R and then send input
to the newly opened console. I can use the following to open the application
...

setwd(path)
system(paste(path,"icl.exe",sep=""))

This allows me to type in what want, but I would like to do something like
this

setwd(path)
system(paste(path,"icl.exe",sep=""),input=c("icl sim.tcl",
"exit"),wait=TRUE)

If I include input as part of the system function the application opens and
then closes immediately without processing the input.

Any assistance that you can offer would be greatly appreciated.

Jonathan Weeks
Doctoral Student
School of Education
University of Colorado, Boulder
[hidden email]
303-517-9666

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Using a console application from within R

Gabor Grothendieck
Don't know how you tell if its working but you need to write

   intern = TRUE

in order to get the output back.  For example, this works for me:

   system("findstr [a-m]", input = letters, intern = TRUE)

On 1/31/06, Jonathan Weeks <[hidden email]> wrote:

> I would like to open a console application from within R and then send input
> to the newly opened console. I can use the following to open the application
> ...
>
> setwd(path)
> system(paste(path,"icl.exe",sep=""))
>
> This allows me to type in what want, but I would like to do something like
> this
>
> setwd(path)
> system(paste(path,"icl.exe",sep=""),input=c("icl sim.tcl",
> "exit"),wait=TRUE)
>
> If I include input as part of the system function the application opens and
> then closes immediately without processing the input.
>
> Any assistance that you can offer would be greatly appreciated.
>
> Jonathan Weeks
> Doctoral Student
> School of Education
> University of Colorado, Boulder
> [hidden email]
> 303-517-9666
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html