admin 管理员组

文章数量: 887021


2023年12月19日发(作者:linux安装vlc)

java实现telnet连接操作package ;import ption;import tream;import tream;import ortedEncodingException;import Exception;import Client;public class WindowsShell { private TelnetClient telnet = new TelnetClient("VT220"); InputStream in; PrintStream out; String prompt = ">"; public WindowsShell(String ip, int port, String user, String password) { try { t(ip, port); in = utStream(); out = new PrintStream(putStream()); login(user, password); } catch (SocketException e) { // TODO Auto-generated catch block tackTrace(); } catch (IOException e) { // TODO Auto-generated catch block tackTrace(); } } /** * 登录 *

* @param user * @param password */ public void login(String user, String password) { // read()Until("login:"); readUntil("login:"); write(user); readUntil("password:"); write(password); readUntil(prompt + ""); } /** * 读取分析结果 *

* @param pattern * @return */ public String readUntil(String pattern) { try { char lastChar = (() - 1); StringBuffer sb = new StringBuffer(); char ch = (char) ();

while (true) { (ch); if (ch == lastChar) {


本文标签: 连接 读取 安装 操作 结果