Skip to content
Prev 80127 / 398502 Next

readline() and Rterm in Windows

I've tried your proposal in a number of ways, and
there must be something I'm not understanding. If I
run your script (using source() in RGui, or ctrl-R
from the R Editor, I get:
Error in file("CONOUT$", "w") : unable to open
connection
In addition: Warning message:
cannot open file 'CONOUT$', reason 'Permission denied'
so I added the path as in:

conout <- file('C:\\R\\R-2.2.0\\CONOUT$','w')
conin <- file('C:\\R\\R-2.2.0\\CONIN$', 'r')
cat('Please enter an ID:', file=conout)
flush(conout)
id <- readLines(conin, 1)
print(id)


Using RGui and ctrl-R from the R Editor, I get
Error in file("C:\\R\\R-2.2.0\\CONIN$", "r") : 
        unable to open connection
In addition: Warning message:
cannot open file 'C:\R\R-2.2.0\CONIN$', reason 'No
such file or directory'
Error in readLines(conin, 1) : object "conin" not
found

and with
Error in file("C:\\R\\R-2.2.0\\CONIN$", "r") : 
        unable to open connection
In addition: Warning message:
cannot open file 'C:\R\R-2.2.0\CONIN$', reason 'No
such file or directory'
When I create a batch file with the following command
:
C:\R\R-2.2.0\bin\Rterm.exe --vanilla
<C:\R\R-2.2.0\foo.R> C:\R\R-2.2.0\foo.out

and double click on the batch file, the out file gives
me:

R : Copyright 2005, The R Foundation for Statistical
Computing
Version 2.2.0  (2005-10-06 r35749)
ISBN 3-900051-07-0
. . .
Type 'q()' to quit R.
and nothing else. In none of the situations do I get
prompted for input. What am I doing hopelessly wrong?

Mikkel
--- Duncan Murdoch <murdoch at stats.uwo.ca> wrote: