• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Problem with Runtime.exec();

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
My application requires me to open a terminal from my program and connect to a remote device and then send and receive commands and responses from tht terminal.

I have used:

My problem is tht a terminal is opening as required...it even starts the telnet session...but before one could start typing the cmds,it abruptly closes(the pgm exits with a value 0).Can someone tell me why this is happening and how i should approach this pbm?
Thanks in advance,
Thejaswini.

P.S: i did not know where to post this...hope am not posting it in the wrong forum.
[ January 17, 2006: Message edited by: thejaswini ramesh ]
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code



This works fine with me. I don't know what is wrong with your setup.
Any ways what are you trying to achieve by opening up the telnet session and ask the user to type?


If you want to communicate with the remote device better use sockets.

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Apache Commons project includes support for Telnet protocol among others. You might look at how they do it.
If you absolutely HAVE to use exec, then you will have to handle the standard in and out streams inside Java because exec grabs control of them - which is probably the source of your problem.
Bill
[ January 18, 2006: Message edited by: William Brogden ]
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic