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

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Executing a CLI command.

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
New Member

Re: Executing a CLI command.

Assuming you have CiscoWorks.

RME, netconfig, adhoc.

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

Blue

Re: Executing a CLI command.

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

Cisco Employee

Re: Executing a CLI command.

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.

Blue

Re: Executing a CLI command.

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

Cisco Employee

Re: Executing a CLI command.

Yes. Do not perform show commands without a redirection.

279
Views
4
Helpful
5
Replies