Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 
Community Member

NCM & Perl Scripting

Hi all,

I am new to NCM but fairly proficient as a script writer and have questions concerning running scripts written in Perl language on NCM. I wrote a simple script that incorporates loops to allow repitition of input. However since NCM generates a form based on the script, I am not sure of what to expect. Any ideas? Thanks for the expected response(s).

Cisco Employee

Re: NCM & Perl Scripting

Hi Ibuomi,

You can enhance CiscoWorks NCM usage through scripting with Diagnostics (the automation of 'show commands' and other CLI input) or Custom Command Scripts, which can automate 'show commands' or even do config changing work, if you require.

The basics are these - if you don't specify 'Advanced Script', then you're essentially doing a basic script which does not allow a programmatic language.  Perl and TCL/Expect are pre-supplied, but you can incorporate any other command language the underlying operating system can support.  A basic script must execute the native language of managed device and NCM handles all the login and prompt handling.

This would be an example of a non-advanced Diagnostic or custom command script that did something with NTP


show ntp association

show ntp status


Now, if you want to do something more programmatic with that, like parsing the results and/or taking action, then you'd need to use the Advanced Scripting option and tell NCM you want to use Perl.

At that point you have to handle the device connectivity (spawn a telnet/SSH), handle the logins and prompts from your script.

In the example above we might write a script that does SSH, handles the banner and prompt determination, executes a 'show ntp status' and parses the output for 'Unsynchronized' or 'stratum 16'.

The 'form' that you allude to is simply the place that you put your Perl code.  There are other fields inside the Job/Task creation screen where you can supply arguments/flags to your script (eg. debug flag, etc).

All script input must be collected at the beginning - once the script is running we can't take additional input.

All script output goes to the STDOUT which is the results screen of the job.  Of course, you can also send output to files, etc.

I hope that helps, if I need to elaborate on anything, let me know!

Jason Davis

Cisco Advanced Services

Community Member

Re: NCM & Perl Scripting

Thanks for clarifying the perspective Jason. You mentioned "All script input must be collected at the beginning - once the script is running we can't take additional input". I wouldn't want to sound redundant but just to clarify, does this imply that loops cannot be used to retrieve input since the script must be running so as to loop?


Cisco Employee

Re: NCM & Perl Scripting

That is essentially correct.  All user input needs to be gained at the beginning of the process.   Now, if you design your script to take
'input' from reading a file or such, that's fine, but there's no way to return to the web UI and ask the user for additional input while the script is running.

For example, I wrote a script that automated some software image update process [yes, I know that NCM can do software upgrades, but we wanted a specific process and use of transport protocols]...  We asked the user for input through the web UI upfront...

Reset boot variables?  Yes/No

Reload device?  Yes/No

Reload now or in the future?   Now / Future

If future, Date?   MM / DD / YYYY

if future, Time?  HH:MM

You get the idea. 

Community Member

Re: NCM & Perl Scripting

Very well put Jason. In that case we shall try to leverage the input using .csv files. What is proposed is to utilize a perl program to generate the .csv files and feed it into the NCM. However I must ask the question of multiple .csv files used to accommodate the various parameters as some are fixed and others rely on looped input. What is the potential of this idea and do you have any sample scripts that utilize multiple .csv files for varying inputs?


Cisco Employee

Re: NCM & Perl Scripting

I don't see any problems with reading external files within loops.  The only concern is trying to return back to a graphic web UI for interactive customer input.  You can't do that.

Unfortunately I can't share my customer commissioned scripts in this forum.  If you want to talk about your situation at length you can reach me at

I might be able to make additional suggestions.

CreatePlease to create content