Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a string as proc args 1

Status
Not open for further replies.

zombieZero

Technical User
Apr 7, 2004
28
US
I have a proc that builds streams on a tester...it doesn't have too many arguments but I've got a suite of tests I'm writing that call for a ton of stream adds and deletes, so I'm looking to make it even simpler by creating a proc that, when fed a minimal number of arguments, will build the stream and add it for me. For example, the original command would look like this:

%tester addStream stream1 port1 {ENCAP IP}

If I feed the new proc the following:

%setStream ip 1 1

Then it runs the command:

%tester addStream $stream

...where $stream is the string "stream1 port1 {ENCAP IP}"

The problem is, addStream is expecting more than one argument, so I get the error 'wrong # args: should be blah blah blah...'

Is there any way to express 'tester addStream $stream' at the prompt and have it understood that I want it to break '$stream' out into its individual arguments?
 
Yes. Use eval.
Code:
proc weirdness {strcmdargs} {
 puts "[eval $strcmdargs]"
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top