Name parameters to runscript?

Does anybody have a nice way of implementing named parameters passed to runscript?

I don’t want to have to worry about the ordering of the parameters I pass or if all the parameters aren’t there (hence throwing off the numbering).

Say I have three parameters to pass to runscript: testhost_name, os_name, os_version.

I can:
runscript MyScript -params MyHost XP 32

for instance.

But I would rather be able to name the parameters, iow, have ‘the parameterList’ act as a propertyList, something like this:

runscript MyScript -params testhost_name:MyHost os_name:XP os_version:32

The only idea I’ve come up with is to have the odd parameters be ‘keys’ and the even parameters be ‘values’. This is prone to all kinds of sadness.

Any other ideas?

You can pass a parameter list in as an argument with a couple of caveats.

First when passing it in through your shell command you need to group it so that it comes in as a single parameter, since you may want to do SenseTalk quotes (") it would probably be best to use single quotes in the shell. Example:

./runscript ~/MySuite/Scripts/MyScript.script -params '(testhost_name:"Machine1",os_name:"Mac10.4")'

Then in the receiving script you’ll need to interpret that parameter by using the value() function to turn it into a proper property list.

params plistString

put value(plistString) into plistParam

put plistParam's testhost_name
put plistParam's os_name

That should give you what you are looking for though, parameters using named arguments.

Thanks. That worked fine. I had to have backslashes all over the place in the shell script and then in Eggplant had to figure out the differences between and uses of param, params, paramerList, but I eventually got it to work.

Then I realized in my environment that the things I wanted to pass as parameters are accessible as env strings from Eggplant. Aargh!

Oh well, it’s an iterative process.

This was definitely a worthwhile exercise though and I will use it again when/if I discover I do need to pass named parameters to Eggplant.