简体   繁体   中英

Runtime.getRuntime.exec()

I am trying to run this command-

Runtime.getRuntime().exec("telnet " + serverIP);

and nothing happens. I am not able to figure out why!

a) Avoid telnet, if possible, because it is so unsecure!

b) You have to pass a program name, which is "telnet", not "telnet ", and add parameters in an array "telnet", "IP", ... .

c) You have to use the whole path to telnet, because Java doesn't evaluate the PATH.

Here is a more complete overview of pitfalls with Runtime.getRuntime ().exec

In addition to "user unknown"s answer:

Telnet is not shiped with Windows Vista and Windows Se7en . You'll have to install it manually.

Also, since telnet communicates over TCP, you should use Sockets to do so in your program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM