Passing multiple parameters via a file

I am having troubles. Here is what I want to accomplish.

I have a controller script that I pass a couple things to from the command line:
-script to run
-temp results location
-options file location

The idea for the options file (in my mind) was that depending on the script that I am going to launch I will have to pass a different number of parameters to the script. So, if I just stuck all of my ‘parameters’ into the script then the controller script doesn’t have to know a head of time how many are going to be passed in. And then the test script itself and go about pulling the information from the file to get the data it needs to complete the test case.

This worked fine if I put 1 value in the file. And I assumed that it was going to work fine with more than 1. However, I tried more than 1 value today and it chokes. So at this point I’m stuck.

Here is the code basically of what I’m trying to accomplish:

** First here is the ‘parameters’ file that I generate (outside of eggplant)
** The path of this file is /tmp/opts-1234 and that value gets passed to the controller script as the 3rd parameter (i.e. inOptionDictionary)
******** file contents******
{
testDomain: “a.domain”
testContainer: “ou=test,dc=a,dc=domain”
}
********** end file contents********

*** Here is the controller script snippet in question:

params scriptName, copyToName, inOptionDictionary
put the value of file inOptionDictionary into optionDictionary
RunWithNewResults scriptName,optionDictionary

*** Here is the test script snippet that will actually try to get the data

params optionDictionary
put optionDictionary.testDomain into domain
put optionDictionary.testContainer into container


It chokes in the controller script on this line:
“put the value of file inOptionDictionary into optionDictionary”

It displays this error:
“Syntax Error at line 1: Syntax Error - can’t understand “testContainer” at or near character 22”

If I take out one of the values in the file, i.e. take out the testContainer: line then it does not complain.

So, what am I doing wrong? What is the correct way to pass an unknown number of parameters to the controller script that can then be read by the test script?

I think it means you left out a comma.
-edj

Yep. I just figured that out. Thanks

Sharon:

Fundamentally what you are doing will work just fine. The problem here is in evaluating the contents of the file. The format that the files is written out in isn’t the same as the in-line formatting for property lists. Also, you have two values for the key “dc”.

You can either write your own stuff to parse that file (yuck) or you can “export” it with a simple little SenseTalk script.

put (testDomain: “a.domain”,testContainer: (ou:“test”,dc:“a”,dd:“domain”)) into file “/tmp/opts-1234”

Let us know if that doesn’t solve it for you.

The idea for the options file (in my mind) was that depending on the script that I am going to launch I will have to pass a different number of parameters to the script. So, if I just stuck all of my ‘parameters’ into the script then the controller script doesn’t have to know a head of time how many are going to be passed in.

It looks like you’ve got the problem with the options file resolved at this point, and I expect that will work well for you. For future reference, I just thought I’d also mention that it’s easy to determine the number of parameters passed to any script or handler by using the paramCount() function and access any of them using the param(n) function. Or you can get all of the passed parameters as a list using the parameterList() function.

Happy scripting! :slight_smile: