- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Perl API NetMRI send variable to run Script broker->script->run
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-09-2018 02:01 AM
Hello I'd like to use python to execute a CSS script in netmri.
The CSS script is very simple:
Ad Hoc Command Batch:
Script-Filter:
true
Script-Variables:
$Commands_to_be_Executed text "Enter commands here, one per line"
########################################################################
Action:
Execute Command Batch
Action-Description:
Execute the commands contained in the Commands_to_be_Executed variable.
Action-Commands:
$Commands_to_be_Executed
########################################################################
The python script is:
....
$Commands_to_be_Executed = "show clock"
script_broker = client.get_broker('Script')
job_id = script_broker.run(name=Ad Hoc Command Batch,device_ids='switch01", script_variables=$Commands_to_be_Executed)
...
The issue is that in python you can't define variables with $, ho can we manage script_broker.run call in this case ?
Solved! Go to Solution.
Re: Perl API NetMRI send variable to run Script broker->script->run
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-09-2018 06:06 AM
Are you just trying to pass a variable into Python or did you want to pass it to another script?
# BEGIN-SCRIPT-BLOCK # # Script-Filter: # true # # Script-Variables: # $command word "show version" # # END-SCRIPT-BLOCK #command will be provided by NenMRI, just use command variable defaults = { "api_url": api_url, "http_username": http_username, "http_password": http_password, "job_id": job_id, "device_id": device_id, "batch_id": batch_id } # Create NetMRI context manager. It will close session after execution with NetMRIEasy(**defaults) as easy: easy.send_command(command)
Twitter: https://twitter.com/sifbaksh
Re: Perl API NetMRI send variable to run Script broker->script->run
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-09-2018 06:11 AM
To run a script you can edit the following for ConfigTemplate
Where $sif : 'siftest' is passing data to a variable
broker = myeasy.broker('ConfigTemplate') sif = {
#this is a TemplateID "id" : '35', "device_ids" : device_id, "$sif" : 'siftest', "$templatemode" : 'bulk' } broker.run (**sif)
Twitter: https://twitter.com/sifbaksh
Re: Perl API NetMRI send variable to run Script broker->script->run
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-11-2018 10:50 PM
I'm scripting in python (on a linux Centos machine) and I'd like to pass variable to a CSS Netmri script the defined variable in CSS script is:
Script-Variables:
$Commands_to_be_Executed
I tried you way:
..
script_broker = client.get_broker('Script')
sif = {
"name" : 'Ad Hoc Command Batch',
"device_ids" : '83',
"$Commands_to_be_Executed" : 'show clock'
}
job_id = script_broker.run(**sif)
..
The Job is executed by the Netmri but the variable $Commands_to_be_Executed doesn't seams to be passed as 'show clock'.
07:40:29 | Script-Variables | |
07:40:29 | ![]() | $commands_to_be_executed = '' |
Re: Perl API NetMRI send variable to run Script broker->script->run
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-11-2018 10:54 PM
...
finally in work ..
"$commands_to_be_executed" : 'show clock'
As to be lowercase !!!! even if in the CSS isn't !

Re: Perl API NetMRI send variable to run Script broker->script->run
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-12-2018 06:45 AM
That is correct, I miss that you were running it from an External box
Everything in NetMRI is lowercase and space is "_"
Twitter: https://twitter.com/sifbaksh