hy, i have a really lame question coming up here, but anyway its driying my small brain out so here it goes: i have a script where you pass paramaters to it sor of #./script fred mike peter sony inside the script i have a load of tests but what i need is that the tests are run on all the paramaters that are passed at command line, so what im looking for is something like: for EACH PARAMETER do test test test test done but i cant figure out how can i pass the paramaters one by one to the test fields. Thnx for your help!.
daniel parkes writes:
i have a script where you pass paramaters to it sor of #./script fred mike peter sony
inside the script i have a load of tests but what i need is that the tests are run on all the paramaters that are passed at command line, so what im looking for is something like:
for EACH PARAMETER do test test test test done
but i cant figure out how can i pass the paramaters one by one to the test fields.
for i in $* do echo $i done Will step through each command line arg and display it. -Ti
Daniel, Ti, On Tuesday 22 November 2005 04:35, Ti Kan wrote:
...
but i cant figure out how can i pass the paramaters one by one to the test fields.
for i in $* do echo $i done
Better, and in accord with a quoting discipline that should be used by all script writers, is this: for i in "$@"; do echo "$i" done And it's also a very good idea to use a loop variable name that means _something_.
...
Randall Schulz
On Tuesday 22 November 2005 17:22, Randall R Schulz wrote:
Daniel, Ti,
On Tuesday 22 November 2005 04:35, Ti Kan wrote:
...
but i cant figure out how can i pass the paramaters one by one to the test fields.
for i in $* do echo $i done
Better, and in accord with a quoting discipline that should be used by all script writers, is this:
for i in "$@"; do echo "$i" done
And it's also a very good idea to use a loop variable name that means _something_.
i = index, plenty of meaning :-) -Stathis
...
Randall Schulz
Stathis, On Tuesday 22 November 2005 06:19, rouvas wrote:
...
And it's also a very good idea to use a loop variable name that means _something_.
i = index, plenty of meaning :-)
You make my point, exactly. It is _not_ and index! Practical, running, production _real_ software is quite a different thing than an isolated algorithm illustrated in a book, where i, j, k and other such meaningless identifiers are acceptable because: 1) There's little or no other code to confuse things; 2) There's a great deal of explanatory and supporting text surrounding the exposition of the algorithm.
-Stathis
Randall Schulz
yep, ok thnx to all!,
works fine!.
The variable name is $SERVERS by the way much more self explanatory for me
in this case.
cya.
On 22/11/05, Randall R Schulz
Stathis,
On Tuesday 22 November 2005 06:19, rouvas wrote:
...
And it's also a very good idea to use a loop variable name that means _something_.
i = index, plenty of meaning :-)
You make my point, exactly. It is _not_ and index!
Practical, running, production _real_ software is quite a different thing than an isolated algorithm illustrated in a book, where i, j, k and other such meaningless identifiers are acceptable because: 1) There's little or no other code to confuse things; 2) There's a great deal of explanatory and supporting text surrounding the exposition of the algorithm.
-Stathis
Randall Schulz
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Daniel, On Tuesday 22 November 2005 08:06, daniel parkes wrote:
yep, ok thnx to all!, works fine!.
The variable name is $SERVERS by the way much more self explanatory for me in this case.
Since I'm in pedantic mode, I'll point out that the variable _name_ is SERVERS. $SERVERS is an expression that dereferences that variable, effectively substituting its value at the time that expression might be executed by the running script into the statement in which it (presumably) appears.
cya.
I will, thanks. Randall Schulz
On Tuesday 22 November 2005 17:47, Randall R Schulz wrote:
Stathis,
On Tuesday 22 November 2005 06:19, rouvas wrote:
...
And it's also a very good idea to use a loop variable name that means _something_.
i = index, plenty of meaning :-)
You make my point, exactly. It is _not_ and index!
Hey, it was intended as a humorous comment!!! BTW, as much as I agree with your comments below, in the context of the script "i" was appearing, it could indeed mean "index", as in "index in the availiable variables". Alternatively, it could be named "v" as in "variable".
Practical, running, production _real_ software is quite a different thing than an isolated algorithm illustrated in a book, where i, j, k and other such meaningless identifiers are acceptable because: 1) There's little or no other code to confuse things; 2) There's a great deal of explanatory and supporting text surrounding the exposition of the algorithm.
Hell, yeah! There are alll sorts of self explanatory names to be used, such as "foo", "goo", "fubar", "tmp", "mispiwoso", "gpp", "route66", "forty_two", "ncc1501a" , etc. Why invent new ones? -Stathis
-Stathis
Randall Schulz
On Tue, 2005-11-22 at 07:47 -0800, Randall R Schulz wrote:
Stathis,
On Tuesday 22 November 2005 06:19, rouvas wrote:
...
And it's also a very good idea to use a loop variable name that means _something_.
i = index, plenty of meaning :-)
You make my point, exactly. It is _not_ and index!
Practical, running, production _real_ software is quite a different thing than an isolated algorithm illustrated in a book, where i, j, k and other such meaningless identifiers are acceptable because: 1) There's little or no other code to confuse things; 2) There's a great deal of explanatory and supporting text surrounding the exposition of the algorithm.
Not to mention that using a name schema that directly relates to what you intend to do, or or doing, makes revisiting things later much easier when you have to figure out what is what. This applies to things where you can assert any kind of name in order to achieve a result. (The CAM software we use allows you to specify a name for certain things which control where the software will operate on any given surface of a solid model. Using the defaults is very undescriptive, and when you have three people working on one job, mind reading becomes a must. I rarely use the defaults and can normally come back to a job two weeks later and pick up right where I have left off with only a review of what I have done, bypassing the what was I trying to do here phase.) Mike
participants (5)
-
daniel parkes
-
Mike McMullin
-
Randall R Schulz
-
rouvas
-
ti@amb.org