s-news
[Top] [All Lists]

Re: Passing arguments to a script file called in batch mode

To: <s-news@wubios.wustl.edu>
Subject: Re: Passing arguments to a script file called in batch mode
From: "Gross, Paul" <paul.gross@blackrock.com>
Date: Fri, 13 Jun 2008 15:25:54 -0400
In-reply-to: <Pine.BSF.4.58L0.0806121907320.32715@boole.maths.tcd.ie>
References: <Pine.BSF.4.58L0.0806121907320.32715@boole.maths.tcd.ie>
Thread-index: AcjMuAKL5MFssH8MRD+zm/u0Ee9+XAAwWkuQ
Thread-topic: [S] Passing arguments to a script file called in batch mode
I have wondered about this too.  For the record, there are several
options:

1. 

In script use, e.g.
a = getenv("a")

Invoke at command line as:  Splus START a=1234 < myscript.q

The following is per previous e-mail with Insightful:

2. Create an environment variable to hold the parameter values, e.g. in
bash

export MYDATA="parameters"

Then in your script, do as in 1 above
args <- getenv("MYDATA")

to extract the environment variable value.  Then, I would run the
following at command line:

> Splus SBATCH infile.q outfile.q

to read in and run the infile.q file.

3. Create a file of the parameters and read it in the infile.q

For example, create file:

> echo parameters > test.in

Then, inside of infile.q call:

x <- scan("test.in", what=<specify param_type>)

Finally, we would run the following at the command prompt:

Splus SBATCH infile.q outfile.q


Note also that commandArgs() in S+ is not equivalent to that in R and is
not adequately documented (and may not even work).



-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Glenn Treacy
Sent: Thursday, June 12, 2008 2:12 PM
To: s-news@wubios.wustl.edu
Subject: [S] Passing arguments to a script file called in batch mode

Hi,

Does anyone know whether it is possible to pass arguments to a script
file that is called in batch mode? I am looking for a way of creating a
dynamic script file that can calls different code depending on the the
value of a variable in a batch file. I have a whole series of script
files that are very similar and this was one idea of consolidating them
into one.

Anyone got an idea?

Thanks in advnace,
Glenn
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news

THE INFORMATION CONTAINED IN THIS MESSAGE AND ANY ATTACHMENT MAY BE PRIVILEGED, 
CONFIDENTIAL, PROPRIETARY OR OTHERWISE PROTECTED FROM DISCLOSURE. If the reader 
of this message is not the intended recipient, you are hereby notified that any 
dissemination, distribution, copying or use of this message and any attachment 
is strictly prohibited. If you have received this message in error, please 
notify us immediately by replying to the message and permanently delete it from 
your computer and destroy any printout thereof.

<Prev in Thread] Current Thread [Next in Thread>