[R] capturing output from Win 98 shell

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Aug 12 18:25:28 CEST 2003


On Tue, 12 Aug 2003, Uwe Ligges wrote:

> Simon Fear wrote:
> > Uwe, you suggest
> > 
> > 
> >>So you almost got it, just read ?shell carefully enough:
> >>
> >>  filenames <- shell("dir D:\\tmp\\*.sasb7dat /b", intern = TRUE)
> >>
> > 
> > 
> > Unfortunately, this does not work and is why I wrote to Rhelp (OK I used
> > system instead of shell, but I tried shell first); here filenames is
> > assigned
> > character(0) even though the dir output is not empty.

It would have beeen helpful to have mentioned that.

> Hmmm. It works on WinNT, and I cannot check a DOS based OS like Win98, 
> because we don't have any of those DOS based operating systems in our 
> department.

shell() also works under WinXP.

> > Believe me I did read ?shell many times before I wrote: but I am
> > reporting
> > that shell does not do what ?shell says it should.

shell() and system() are a low-level interface (written by Guido M) that
work hard to capture the stdin and stdout.  It seems your shell is not
actually sending its printout to stdout, so it does not get captured.  
That's quite consistent with what ?shell says it does.

The normal way out is to use a better shell: we used to use one called
cmd32.exe (I believe) to get Emacs to be able to do this.

If you insist on using a long-obselete OS, please help us continue ot 
support it by supplying patches and workarounds.  I think we (like 
Microsoft) are going to have to think seriously about withdrawing support 
from non-NT-based versions of Windows fairly soon.

-- 
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




More information about the R-help mailing list