简体   繁体   English

Runtime.getRuntime.exec()

[英]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! a)如果可能,请避免使用telnet,因为它太不安全了!

b) You have to pass a program name, which is "telnet", not "telnet ", and add parameters in an array "telnet", "IP", ... . b)您必须传递一个程序名称,即“ telnet”,而不是“ telnet”,并在数组“ telnet”,“ IP”,...中添加参数。

c) You have to use the whole path to telnet, because Java doesn't evaluate the PATH. c)您必须使用telnet的整个路径,因为Java不会评估PATH。

Here is a more complete overview of pitfalls with Runtime.getRuntime ().exec 这是Runtime.getRuntime().exec陷阱的更完整概述

In addition to "user unknown"s answer: 除了“用户未知”的答案:

Telnet is not shiped with Windows Vista and Windows Se7en . Windows VistaWindows Se7en不附带Telnet。 You'll have to install it manually. 您必须手动安装。

Also, since telnet communicates over TCP, you should use Sockets to do so in your program. 另外,由于telnet通过TCP进行通信,因此您应该在程序中使用Sockets进行通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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