Skip to content
Prev 178791 / 398506 Next

send command to other program

Jim Lemon wrote:
if your r code produces just the file names, each on a separate line,
and the other program takes file names from the args list with no
particular option needed to specify them, you might try:

    r <your r script> | xargs <your program>
    <your program> $(r <your r script>)

as in

    # dummy files and scripts
    echo "foo" > foo
    echo "bar" > bar
    echo "cat(paste(c('foo', 'bar'), '\n', collapse=''))" > script.r
    echo 'for f in "$@"; do echo "input: $f"; done' > program
    chmod 755 program

    r script.r | xargs ./program
    ./program $(r script.r)
  
you may need to adapt the pattern to a shell other than bash.

vQ