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

______________________________________________
R-help@r-project.org 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.

Reply via email to