[R] get the command line

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Sep 7 06:07:49 CEST 2009


On Mon, Sep 7, 2009 at 12:00 AM, Peng Yu<pengyu.ut at gmail.com> wrote:
> On Sun, Sep 6, 2009 at 10:50 PM, Steve
> Lianoglou<mailinglist.honeypot at gmail.com> wrote:
>> Hi,
>>
>> On Sun, Sep 6, 2009 at 11:25 PM, Peng Yu<pengyu.ut at 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




More information about the R-help mailing list