cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1659
Views
4
Helpful
5
Replies

Executing a CLI command.

nishchal.a
Level 1
Level 1

Hello

I wanted to enquire if there is any way by which I can execute a CLI command programmatically or even through an SNMP request.

I need to execute a CLI command(not through telenet etc) on a Cisco 1200 series AP in such a way.

Thanks

Nishchal

5 Replies 5

rdanevich
Level 1
Level 1

Assuming you have CiscoWorks.

RME, netconfig, adhoc.

SNMP may also be possible, however this method is much more complex.

yjdabear
VIP Alumni
VIP Alumni

If you are not rejecting telnet or ssh as the underlying mechanism completely, check out Expect, which makes what you're looking to do a trivial task:

http://expect.nist.gov

http://en.wikipedia.org/wiki/Expect

Joe Clarke
Cisco Employee
Cisco Employee

The advice thus far has been about executing CLI commands via telnet. This is not what you want. There is a little-known trick where you can execute a CLI command via SNMP. To do this, you need to push a config snippet to the device's RUNNING CONFIG using the CISCO-CONFIG-COPY-MIB procedure outlined at http://www.cisco.com/en/US/tech/tk648/tk362/technologies_tech_note09186a0080094aa6.shtml .

Your config snippet should contain the following:

do

end

For example:

do clear line 1

end

If you need to execute a show command, and save the output, you will need to use the redirect feature. For example:

do show ver | redirect flash:show_ver.txt

end

BE VERY CAREFUL you DO NOT do any interactive commands using this trick. If you do, you will lock the config until you next reload the device.

In the example above, is "do show ver" without the pipe considered an "interactive" command, i.e., does that lock the config?

Yes. Do not perform show commands without a redirection.