Skip to content
Back to formatted view

Raw Message

Message-ID: <alpine.DEB.2.00.0904240957280.20675@taxa.psych.umn.edu>
Date: 2009-04-24T15:04:53Z
From: Mike Miller
Subject: use of "input" in system()
In-Reply-To: <alpine.DEB.2.00.0904240928420.20675@taxa.psych.umn.edu>

On Fri, 24 Apr 2009, Mike Miller wrote:

> I am running bash, but system calls go to sh.  I want to be able to put 
> that input string ("0005") into a variable and do something like this:
>
> system( "i=`cat /dev/stdin` ; run_script > file${i}.out" , input=sprintf("%04d", i) )


In sh, both of these commands execute ls:

echo ls | `cat /dev/stdin`
echo ls | `cat -`

In R, both of these simply hang until I hit ctrl-c...

> system( "`cat /dev/stdin`", input="ls" )
> system( "`cat -`", input="ls" )

...but the stdin is getting to the command because both of these return 
"ls" to stdout:

> system( "cat -", input="ls" )
> system( "cat /dev/stdin", input="ls" )


So what am I missing?  I don't understand why the backtick method isn't 
working.  Is there another way to do this?

Mike