[R] system shell emulation in R

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jun 24 23:30:40 CEST 2004


On Thu, 24 Jun 2004, Shin, Daehyok wrote:

> Is it difficult in R to create a function calling system() with user's
> inputs iteratively?

See the example below!

> 
> Daehyok Shin (Peter)
> 
> > -----Original Message-----
> > From: r-help-bounces at stat.math.ethz.ch
> > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Prof Brian Ripley
> > Sent: Thursday, June 24, 2004 PM 2:28
> > To: Shin, Daehyok
> > Cc: R, Help
> > Subject: Re: [R] system shell emulation in R
> >
> >
> > On Thu, 24 Jun 2004, Shin, Daehyok wrote:
> >
> > > Rather than using system() to execute a shell command,
> > > is there a way to emulate the system shell itself in R?
> > > For instance, if the function is shell,
> > >
> > > > getwd()
> > > [1] "/home/a/b"
> > > > shell()          # From R to system shell
> > > $cd ..              # cd command in system shell
> > > $CTRL+D	       # Return to R
> > > > getwd()
> > > [1] "/home/a"
> >
> > system("/bin/sh") does this for you under a Unix-alike.  But as spawning a
> > shell as cd-ing in the child does not change the working directory of the
> > parent, the emulation would be imperfect if this worked in R.
> >
> > Do try it in your favourite shell!
> >
> > --
> > 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
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.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




More information about the R-help mailing list