aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes how to execute commands on router using java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "how to execute commands on router using java code" Watch "how to execute commands on router using java code" New topic
Author

how to execute commands on router using java code

NagarajGoud uppala
Ranch Hand

Joined: Nov 13, 2008
Posts: 86
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.



I know Life is very Tough...But I AM TOUGHER
SCJP 1.5
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
NagarajGoud uppala
Ranch Hand

Joined: Nov 13, 2008
Posts: 86
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

Joined: Jan 01, 2007
Posts: 368
Try the sample code here: http://hc.apache.org/httpclient-3.x/tutorial.html


Thanks and Regards
NagarajGoud uppala
Ranch Hand

Joined: Nov 13, 2008
Posts: 86
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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?


Ping & DNS - updated with new look and Ping home screen widget
NagarajGoud uppala
Ranch Hand

Joined: Nov 13, 2008
Posts: 86
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Cisco hardware is rather expensive - I'd expect there to be extensive documentation available on Cisco's web site.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to execute commands on router using java code
 
Similar Threads
Execute IOS commands from java code in Linux environment
ssh connection with java code.
windows command
Connecting to a router
how to connect router using java application