Sending variables to cli script from control script

Post Reply
earcuri
Member
Posts: 1
Joined: 12 Sep 2012 18:11

Sending variables to cli script from control script

Post by earcuri » 12 Sep 2012 18:29

I am very new to SAM (been using it for exactly 1 day) and am trying to create a control script that will call 2 different cli scripts to provision a vlan across 2 different switches.
I have read the docs and I thought that I had it correct using .addVariable but every variable is null when it calls the cli script.

The vlanID is defined in velocity via a string in the ui that the user puts in. When executing the flow and clicking on preview the vlanID is set properly, it just doesn't pass it to the cli script the way that I thought it would.
If I use the exact same velocity code in the cli script (with no control script) it works fine. I just can't get the variable (value) for vlanID passed to the cli script

Here is the code:

Code: Select all

#set ( $myScript = $alCtrl.defineCliScriptInvoker('VLAN - CliScript') )

$myScript.addVariable('string','$vlanID4Switch, $vlanID)

$myScript.invokeScript('10.10.10.180')
Thanks in advance.

Gary_t
Member
Posts: 2
Joined: 27 Nov 2013 09:24

Re: Sending variables to cli script from control script

Post by Gary_t » 27 Nov 2013 09:29

Did you ever figure this out? I'm in pretty much the same situation.

When I execute the CLI script - it just stays 'in progress', it doesn't appear to generate any of the required CLI commands. Running it as a stand alone CLI script, it works fine.

I know this is an old message I've brought back up - hoping someone has a bit of experience with these scripts in SAM.

Thanks,
Gary

Gary_t
Member
Posts: 2
Joined: 27 Nov 2013 09:24

Re: Sending variables to cli script from control script

Post by Gary_t » 02 Dec 2013 09:12

Well, I got my scripts working. Also learned a couple things along the way.

The issue with the earcuri's script is in the addVariable line. The 2nd parameter in there shouldn't be a variable (leading '$'), it is just the name of the variable that the called script uses once this info is passed in (ie 'VLAN - CliScript' has a variable $vlanId4Switch).

Other bits:
Control/called scripts must be 'bound' together via the GUI scripts interface.
Called scripts can not have any control logic embedded (ie alCtrl / alScript / etc). If you have that - the called script will simply hang and never execute.

Hope that can help someone else along the way.
Gary

Post Reply

Return to “5620 SAM”