• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to execute commands on router using java code

 
NagarajGoud uppala
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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.


 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cisco hardware is rather expensive - I'd expect there to be extensive documentation available on Cisco's web site.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic