• 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

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 ]
 
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic