• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to execute commands on router using java code

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am using http protocol to connect router .
i connected successfully. after that i want
to execute commands on router.how can
i execute it?
i used like this

but it is only support for command line
please focus some light on this.

thanks,
nagaraju.


 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your router supports SSH or Telnet, I would use a proper library for that. You can find some on Google. If not, and HTTP is the only options, then you simply won't be able to send it commands other than those already available on its web management console. You can use something like Apache's HttpClient to execute GET and POST request.
 
NagarajGoud uppala
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob Prime,
can you give sample example how to use them for send commands like

Apache's HttpClient to execute GET and POST request.


sh runn
i tried to find but i didn't understand which methods i need to use
please help me

Thanks in advance,
Nagaraju
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try the sample code here: http://hc.apache.org/httpclient-3.x/tutorial.html
 
NagarajGoud uppala
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Satya Maheshwari wrote:Try the sample code here: http://hc.apache.org/httpclient-3.x/tutorial.html



Hi Satya Maheswari,
thanks for your help. i am able to connect router, i tried to execute a command on router "sh runn"
but i am not getting any thing
sample code


is it correct way to send a command to router?
please any one help me

Thanks in advacne,
Nagaraju
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you certain that the way to get the router to do something is to POST "sh runn" to it? Is that what its documentation says to do? What is the response of the router?
 
NagarajGoud uppala
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf Dittmer,
Thanks for your reply.

Ulf Dittmer wrote:Are you certain that the way to get the router to do something is to POST "sh runn" to it? Is that what its documentation says to do?

i am not sure

i connected to router
sample code

What is the response of the router


i am getting status 500

i know it is server error i.e router
i don't know what is the problem internally.

after connecting to the server i want execute a the "show run-configuration" command
then read the response.
can any one give the idea or sample code to execute that command on router
my router is "cisco 2161"

Thanks in advance,
Nagaraju.


 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cisco hardware is rather expensive - I'd expect there to be extensive documentation available on Cisco's web site.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic