[R] multiline system call
Charles C. Berry
cberry at tajo.ucsd.edu
Fri Dec 22 23:31:22 CET 2006
On Fri, 22 Dec 2006, Gabor Grothendieck wrote:
> Its only available on Windows.
Right, but on linux this works
> system("echo x\necho y",intern=T)
[1] "x" "y"
> system("echo x ; echo y",intern=T)
[1] "x" "y"
so you don't really need input=...
But rereading Nicolas original post, it looks like the problem is
terminating the input with a ctrl-D.
Perhaps a workaround is to pipe the input into sendmail (I recall sendmail
accepts input from sdtin) from 'echo'
Note that the single quotes are needed to protect the '\n's until echo is
ready to act:
> system("echo 'a \n b \n c' | wc ",intern=T)
[1] " 3 3 10"
>
I have exim - not sendmail, but this sends a msg from/to me on my linux
box:
system("echo 'To:cberry\nthis is a test' | /usr/sbin/exim -f cberry at tajo.ucsd.edu -t "
Maybe this will work for Nicolas.
>
> On 12/22/06, Nicolas Mazziotta <nicolas.mazziotta at swing.be> wrote:
>> Dear Sir,
>>
>> Le vendredi 22 décembre 2006 20:05, vous avez écrit :
>>> system("sh",intern=T,input=c("echo x","echo y"))
>>
>> Thanks for the advice, but I do not find doc about the input arg for the
>> system function. Besides,
>>
>> $> system("sh",intern=T,input=c("echo x","echo y"))
>> Erreur dans system("sh", intern = T, input = c("echo x", "echo y")) :
>> unused argument(s) (input = c("echo x", "echo y"))
>>
>> Is R version 2.4.0 (2006-10-03) too old?
>>
>> Best regards,
>>
>>
>> --
>> Nicolas Mazziotta
>>
>> The contents of this e-mail, including any attachments, are ...{{dropped}}
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch 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.
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717
More information about the R-help
mailing list