cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1573
Views
0
Helpful
6
Replies

NCM Expect references

bdemeulmeester
Level 1
Level 1

Expect references

I am starting to get into expect scripting for NCM but I keep running into roadblocks. The NCM documentation does not go into very good details on using expect scripts. It has good references to Java, Perl and SOAP but none to expect nor does it have a good reference to the NCM command line. I am not a Unix guru so I don't know much about expect. Does anyone know of a good reference for these?

6 Replies 6

Not applicable

I think Script Adapter (notifier) in NCM helps you. The Script Adapter (Notifier) allows you to automatically take an action when a notification is received. Upon receiving a notification, the Script Notifier invokes a custom script supplied by you that performs user-defined actions. For example, you can create a Script Notifier to send a page, using a paging service. Another Script Notifier might invoke an audible alarm when mission critical notifications are received.

Following URL helps you to configure script adapter:

http://www.cisco.com/en/US/docs/net_mgmt/cisco_network_connectivity_monitor/1.0/user/guide/notification_adapt_script.html#wp1030214

I was looking more for a syntax of the except scripting language that NCM uses.

NCM uses the standard Tcl-based expect scripting language. A sample expect script can be found in the NCM user's guide in appendix C. I've included it here:

#

# Sample Script to set the banner only if

# it is not already set correctly

#

spawn telnet $tc_device_ip$

set banner "****Unauthorized Access Prohibited****"

expect {

$banner {

puts "\nBanner is already set correctly\n"

exit 0

} "word:"

}

send "$tc_device_password$\r"

expect ">"

send "en\r"

expect "word:"

send "$tc_device_enable_password$\r"

expect "\#"

send "config t\r"

expect "\#"

send "banner motd /$banner/\r"

expect "\#"

send "exit"

More on the expect language can be found at http://expect.nist.gov/ . Help on the Tcl scripting language can be found at http://www.tcl.tk/man/tcl8.4/ . The NCM user's guide can be found at http://tools.cisco.com/search/display?url=http%3A%2F%2Fwww.cisco.com%2Fen%2FUS%2Fdocs%2Fnet_mgmt%2Fciscoworks_network_compliance_manager%2F1_3_SP1%2Fuser_guide%2FUser_Guide.pdf&pos=1&strqueryid=3&websessionid=4ozdHO6hBKp-BWwCZYVlXIo .

Here's a brief expect tutorial link you may find useful:

http://www.gnulamp.com/expect.html

yjdabear
VIP Alumni
VIP Alumni

I find the following sites extremely helpful in showing practical examples of Expect:

http://wellho.net/forum/index.html

http://wiki.tcl.tk/201

Thanks! I appriciate the help.

Review Cisco Networking for a $25 gift card