A simple example follows. The file is called Test.R # Example rm(list=is(all=TRUE)) cat("Enter file name") fn<-scan(what="") I execute the following: @C:\PROGRA~1\R\R-2.4.1\bin\Rterm.exe --no-restore --no-save < Test.R > Rout.txt I do not see the "Enter file name" or have the opportunity to enter the file name. I am running R in windows XP. Thanks for your help. John H Schuenemeyer Southwest Statistical Consulting, LLC 960 Sligo St Cortez, CO 81321-2558 Phone: 970.565.0179 URL: www.swstatconsult.com [[alternative HTML version deleted]]
First I think you should have 'ls(' instead of 'is('. Second, your standard input if from the Test.R file so you scan won't be reading from the console. Here is what I got when I changed 'is' to 'ls': /cygdrive/c/progra~1/r/r-2.4.1/bin: ./rterm --no-save <c:/test.r R version 2.4.1 (2006-12-18) Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.> rm(list=ls(all=TRUE)) > cat("Enter file name")Enter file name> fn<-scan(what="") 1: Read 0 items>/cygdrive/c/progra~1/r/r-2.4.1/bin: You can see that nothing as read and the 'Enter file name' was there. On 3/14/07, John Schuenemeyer <jackswsc@beyondbb.com> wrote:> > A simple example follows. The file is called Test.R > # Example > rm(list=is(all=TRUE)) > cat("Enter file name") > fn<-scan(what="") > > I execute the following: > @C:\PROGRA~1\R\R-2.4.1\bin\Rterm.exe --no-restore --no-save < Test.R > > Rout.txt > > I do not see the "Enter file name" or have the opportunity to enter the > file name. I am running R in windows XP. > > Thanks for your help. > > John H Schuenemeyer > Southwest Statistical Consulting, LLC > 960 Sligo St > Cortez, CO 81321-2558 > > Phone: 970.565.0179 > > URL: www.swstatconsult.com > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
This is much easier in R-devel: just use message() and scan("stdin"). gannet% cat Test.R message("Enter file name: ", appendLF=FALSE) fn <- scan("stdin", what="", n=1) works for me in R-devel via R --vanilla -f Test.R > Rout.txt I believe it also works under Windows. On Wed, 14 Mar 2007, John Schuenemeyer wrote:> A simple example follows. The file is called Test.R > # Example > rm(list=is(all=TRUE)) > cat("Enter file name") > fn<-scan(what="") > > I execute the following: > @C:\PROGRA~1\R\R-2.4.1\bin\Rterm.exe --no-restore --no-save < Test.R > Rout.txt > > I do not see the "Enter file name" or have the opportunity to enter the file name. I am running R in windows XP. > > Thanks for your help. > > John H Schuenemeyer > Southwest Statistical Consulting, LLC > 960 Sligo St > Cortez, CO 81321-2558 > > Phone: 970.565.0179 > > URL: www.swstatconsult.com > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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.PLEASE do, and not send HTML. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595