• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Connecting to a router

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I want to make a program to connect to a router using Http protocol or Telnet protocol.
I tried running a command prompt on my PC and connecting to the router using telnet commands i used the Process class but i failed

Thank you in advance
 
Sheriff
Posts: 21760
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

java telnet leads to several Telnet libraries. Surprisingly, Apache Commons Net isn't found on the first two pages, so I thought I'd mention it explicitly.

HTTP is probably going to be more difficult as it will certainly involve a bit more complex requests. HttpClient can be a great help.
 
ahmed abobakr
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Rob Spoor


how can i send multiple commands to command prompt?

I tried this code. what the error here?

this program didn't have syntax errors.

 
Rob Spoor
Sheriff
Posts: 21760
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't use such a large font. I've had to remove the formatting on both of your posts already. Also, UseCodeTags from now on. See how much easier your code is to read.

Why didn't you use a Telnet library like I suggested?
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the command-line Telnet client on your system really called "telent"?
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Windows telnet client is a GUI client that doesn't take commands on the command line; something tells me he's just using that stock client, anyway.
 
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the router really accept Telnet requests?

One issue to be aware of is Don't println to a Socket, which the code is doing by using readLine.
 
Rob Spoor
Sheriff
Posts: 21760
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a slight difference. readLine is able to handle \r, \n and \r\n as line breaks. It did (does?) have a bug that if the stream ends with a \r without a \n after it, readLine would block.
 
ahmed abobakr
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for helping me

I think i found the solution to my problem here


but i don't know how can i press the carriage return?
 
Rob Spoor
Sheriff
Posts: 21760
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A carriage return is just the character '\r'. You can include that in Strings as you would any other character.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!