Passing command line parameters as list

Hi,

I have the following requirements:

In the command line executtion after -params option, I have to pass 2 parameters but each parameter could be a list:

parameter 1: (p11,p12)
parameter 2: (p21,p22)

So I'm passing the parameters exactly as shown above. How do I save them as list in the main script using "params" command.

Possible soultion:

Main Script:

params cmd_p1,cmd_p2...

function f1 (cmd_p1) // Will it pass the whole list (p11,p12)

Thanks in advance.

Comments

  • I don't know if you can send in a list, but a simple workaround for your problem may be to use files where you specify your list of params.

    You can read your file from eggplant easily enough.

    params.txt
    p1, p2, p3
    p4, p5, p1
    
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    When you call a script from the command line, parameters can only be passed as text strings (the shell doesn't understand SenseTalk lists or property lists). So, to pass in a list safely, you'll need to do a couple of things. First, quote the parameters on the command line, something like this:
    /Applications/Eggplant.app/runscripts /path/to/your/script -params "(p11,p12)" "(p21,p22)"
    

    Then, in your script, you can use the value function to turn these values into lists:
    params firstParam, secondParam
    set list1 to value(firstParam)
    set list2 to value(secondParam)
    

    If you have a lot of data you want to pass in, putting it in a file as bharathh suggested may be a better solution.
Sign In or Register to comment.