On Mon, Sep 7, 2009 at 12:00 AM, Peng Yu<pengyu...@gmail.com> wrote:
> On Sun, Sep 6, 2009 at 10:50 PM, Steve
> Lianoglou<mailinglist.honey...@gmail.com> wrote:
>> Hi,
>>
>> On Sun, Sep 6, 2009 at 11:25 PM, Peng Yu<pengyu...@gmail.com> wrote:
>>> Hi,
>>>
>>> commandArgs gives me the arguments. I am wondering what command can
>>> give the whole command line.
>>
>> What does "the whole command line" mean? Are you looking for the
>> command args in one string?
>>
>> paste(commandArgs(), collapse=" ")
>>
>> Can you give an example of what you're trying to get?
>
> For example, I run the following command in bash.
>
> Rscript some_script.R a b c
>
> I want to get the string "Rscript some_script.R a b c" in the script
> some_script.R.

If I print each arg in commandArgs() on its own line, when I call:

Rscript test.R a b c

I get:

    /Library/Frameworks/R.framework/Resources/bin/exec/i386/R
    --slave
    --no-restore
    --file=test.R
    --args
    a
    b
    c

>From that you can reconstruct the command line pretty easily, except
for the missing "Rscript" part ...  is that what's concerning you? I'm
not sure how you would go about getting the Rscript, if that's what
you're after ...

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

______________________________________________
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