[R] capturing output from Win 98 shell

Simon Fear Simon.Fear at synequanon.com
Tue Aug 12 16:16:39 CEST 2003


How can I best achieve the following (works in Splus):

filenames <- dos("dir *.sasb7dat /b")

What I am  asking, more generically, is: how can I capture the output of
a
DOS command in R?

I have tried using

system("COMMAND.COM /c dir /b", intern=T, show.output.on.console=T)

where

  intern: a logical, indicates whether to make the output of the
          command an R object.

but it makes no useful difference:

> system("COMMAND.COM /c dir /b", intern=T, show.output.on.console=T)
character(0)
> print(system("COMMAND.COM /c dir /b", intern=F,
show.output.on.console=T))
[1] 0

In both cases here a DOS window opens and lists a couple of hundred
files,
before giving the above output.

I am also a bit baffled by "show.output.on.console" whose only effect
seems
to be on whether the DOS screen opens for one millisecond or for one
second.
It does not, per help, "show the output of the command on the R
console".

Incidentally I can answer the problem at hand using the following
workaround
(but what I'm after is a more generic solution):

shell("dir D:\\tmp\\*.sasb7dat /b > D:\\tmp\\Paula\\dirlist.lst")
dataset.names <- scan("D:\\tmp\\dirlist.lst", what="", sep="\n")

TIA
SF
 

Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: Simon.Fear at synequanon.com
web: http://www.synequanon.com
 
Number of attachments included with this message: 0
 
This message (and any associated files) is confidential and\...{{dropped}}




More information about the R-help mailing list