• <em id="6vhwh"><rt id="6vhwh"></rt></em>

    <style id="6vhwh"></style>

    <style id="6vhwh"></style>
    1. <style id="6vhwh"></style>
        <sub id="6vhwh"><p id="6vhwh"></p></sub>
        <p id="6vhwh"></p>
          1. 国产亚洲欧洲av综合一区二区三区 ,色爱综合另类图片av,亚洲av免费成人在线,久久热在线视频精品视频,成在人线av无码免费,国产精品一区二区久久毛片,亚洲精品成人片在线观看精品字幕 ,久久亚洲精品成人av秋霞

            java如何連續(xù)執(zhí)行多條cmd命令

            更新時(shí)間:2023-12-09 21:20:44 閱讀: 評(píng)論:0

            2023年12月9日發(fā)(作者:伴玩)

            -

            java如何連續(xù)執(zhí)行多條cmd命令

            java如何連續(xù)執(zhí)行多條cmd命令

            java連續(xù)執(zhí)行多條cmd命令

            命令之間用&連接

            例如:

            Process p = time().exec("cmd /c d: & cd bin/");

            java ssh登錄執(zhí)行多條cmd命令

            java登錄ssh執(zhí)行多條命令,解決出現(xiàn)more自動(dòng)回車的問題

            import ption;

            import tream;

            import Stream;

            import ortedEncodingException;

            import ager;

            import ;

            import l;

            import ;

            import ception;

            import n;

            import oardInteractive;

            import fo;

            public class JavaSsh implements Runnable {

            protected Logger logger = ger();

            /**

            * 退格

            */

            private static final String BACKSPACE = new String(new byte[] { 8 });

            /**

            * ESC

            */

            private static final String ESC = new String(new byte[] { 27 });

            /**

            * 空格

            */

            private static final String BLANKSPACE = new String(new byte[] { 32 });

            /**

            * 回車

            */

            private static final String ENTER = new String(new byte[] { 13 });

            /**

            * 某些設(shè)備回顯數(shù)據(jù)中的控制字符

            */

            private static final String[] PREFIX_STRS = { BACKSPACE + "+" + BLANKSPACE + "+" + BACKSPACE + "+",

            "(" + ESC + "[d+[A-Z]" + BLANKSPACE + "*)+" };

            private int sleepTime = 200;

            /**

            * 連接超時(shí)(單次命令總耗時(shí))

            */

            private int timeout = 4000;

            /**

            * 保存當(dāng)前命令的回顯信息

            */

            protected StringBuffer currEcho;

            /**

            * 保存所有的回顯信息

            */

            protected StringBuffer totalEcho;

            private String ip; private int port; private String endEcho = "#,?,>,:"; private String moreEcho = "---- More ----"; private String moreCmd = BLANKSPACE; private JSch jsch = null; private Session ssion; private Channel channel;

            @Override public void run() { InputStream is; try { is = utStream(); String echo = readOneEcho(is); while (echo != null) { (echo); String[] lineStr = ("n"); if (lineStr != null && > 0) { String lastLineStr = lineStr[ - 1]; if (lastLineStr != null && f(moreEcho) > 0) { (e(lastLineStr, "")); } el { (echo); } } echo = readOneEcho(is); } } catch (IOException e) { tackTrace(); } }

            protected String readOneEcho(InputStream instr) { byte[] buff = new byte[1024]; int ret_read = 0; try { ret_read = (buff); } catch (IOException e) { return null; } if (ret_read > 0) { String result = new String(buff, 0, ret_read); for (String PREFIX_STR : PREFIX_STRS) { result = eFirst(PREFIX_STR, ""); } try { return new String(es(), "GBK"); } catch (UnsupportedEncodingException e) { tackTrace(); return null; } } el { return null; } }

            public JavaSsh(String ip, int port, String endEcho, String moreEcho) { = ip; = port; if (endEcho != null) { o = endEcho; } if (moreEcho != null) { ho = moreEcho; } totalEcho = new StringBuffer(); currEcho = new StringBuffer(); }

            private void clo() { if (ssion != null) { nect(); } if (channel != null) { nect(); } }

            private boolean login(String[] cmds) { String ur = cmds[0]; String passWord = cmds[1]; jsch = new JSch(); try { ssion = sion(ur, , ); sword(passWord); UrInfo ui = new SSHUrInfo() { public void showMessage(String message) { }

            public boolean promptYesNo(String message) { return true; } }; rInfo(ui); t(30000); channel = annel("shell"); t(3000); new Thread(this).start(); try { (sleepTime); } catch (Exception e) { } return true; } catch (JSchException e) { return fal; } }

            protected void ndCommand(String command, boolean ndEnter) { try { OutputStream os = putStream(); (es()); (); if (ndEnter) { currEcho = new StringBuffer(); (es()); (); } } catch (IOException e) { tackTrace(); } }

            protected boolean containsEchoEnd(String echo) { boolean contains = fal; if (endEcho == null || ().equals("")) { return contains; } String[] eds = (","); for (String ed : eds) { if (().endsWith(ed)) { contains = true; break; } } return contains; }

            private String runCommand(String command, boolean ifEnter) { currEcho = new StringBuffer(); ndCommand(command, ifEnter); int time = 0; if (endEcho == null || ("")) { while (ng().equals("")) { try { (sleepTime); time += sleepTime; if (time >= timeout) { break; } } catch (InterruptedException e) { tackTrace(); } } } el { while (!containsEchoEnd(ng())) { try { (sleepTime); } catch (InterruptedException e) { tackTrace(); } time += sleepTime; if (time >= timeout) { break; } String[] lineStrs = ng().split("n"); if (lineStrs != null && > 0) { if (moreEcho != null && lineStrs[ - 1] != null && lineStrs[ - 1].contains(moreEcho)) { ndCommand(moreCmd, fal); ("n"); time = 0; continue; } } } } return ng(); }

            private String batchCommand(String[] cmds, int[] othernEenterCmds) { StringBuffer sb = new StringBuffer(); for (int i = 2; i < ; i++) { String cmd = cmds[i]; if (("")) { continue; } boolean ifInputEnter = fal; if (othernEenterCmds != null) { for (int c : othernEenterCmds) { if (c == i) { ifInputEnter = true; break; } } } cmd += (char) 10; String resultEcho = runCommand(cmd, ifInputEnter); (resultEcho); } clo(); return ng(); }

            public String executive(String[] cmds, int[] othernEenterCmds) { if (cmds == null || < 3) { ("{} ssh cmds is null", ); return null; } if (login(cmds)) { return batchCommand(cmds, othernEenterCmds); } ("{} ssh login error", ); return null; }

            private abstract class SSHUrInfo implements UrInfo, UIKeyboardInteractive { public String getPassword() { return null; }

            public boolean promptYesNo(String str) { return true; }

            public String getPassphra() { return null; }

            public boolean promptPassphra(String message) {

            return true;

            }

            public boolean promptPassword(String message) {

            return true;

            }

            public void showMessage(String message) {

            }

            public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt,

            boolean[] echo) {

            return null;

            }

            }

            public static void main(String[] args) {

            String ip = "192.168.0.238";

            int port = 22;

            JavaSsh JavaSsh2 = new JavaSsh(ip, port, null, null);

            String urname = "ssh";

            String password = "";

            String[] cmds = { urname, password, "display mac-address", "display mac-address" };

            String executive = ive(cmds, null);

            n(executive);

            }

            }

            以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持。

            -

            java如何連續(xù)執(zhí)行多條cmd命令

            本文發(fā)布于:2023-12-09 21:20:44,感謝您對(duì)本站的認(rèn)可!

            本文鏈接:http://www.newhan.cn/zhishi/a/170212804440123.html

            版權(quán)聲明:本站內(nèi)容均來自互聯(lián)網(wǎng),僅供演示用,請(qǐng)勿用于商業(yè)和其他非法用途。如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除。

            本文word下載地址:java如何連續(xù)執(zhí)行多條cmd命令.doc

            本文 PDF 下載地址:java如何連續(xù)執(zhí)行多條cmd命令.pdf

            下一篇:返回列表
            標(biāo)簽:命令   回顯   希望   執(zhí)行
            留言與評(píng)論(共有 0 條評(píng)論)
               
            驗(yàn)證碼:
            推薦文章
            排行榜
            • 爆笑的笑話
              綠豆莢-三幫車視2023年3月16日發(fā)(作者:森林運(yùn)動(dòng)會(huì))1幽默笑話大全爆笑經(jīng)典短信幽默笑話大全爆笑1、口誤傷不起呀:一次坐公交車,到某站臺(tái)時(shí),司機(jī)突然問到:有人下車么,沒人我下啦!頓時(shí)車上笑做一團(tuán)。2、聽說你工作瘋狂,難道是愛共產(chǎn)黨,領(lǐng)導(dǎo)大家人人夸,能明白多么恨你,可否癡心改一改。(請(qǐng)看每句第三個(gè)字。)3、工作是苦是累,我們積極面對(duì),干好職屬分內(nèi),與同事友好相對(duì),拿到工資問心無愧;花得自在,用得
            • 1202℃五兒孝母
            • 967℃幽默笑話段子
            • 960℃戀愛說說
            • 923℃陳大惠老師
            • 571℃銀行印鑒卡
            • 490℃湯姆索亞歷險(xiǎn)記梗概
            • 471℃開心丁月五香天
            • 454℃舉例子的作用
            • 397℃聯(lián)想思維
            Copyright ?2019-2022 Comsenz Inc.Powered by ? 實(shí)用文體寫作網(wǎng)旗下知識(shí)大全大全欄目是一個(gè)全百科類寶庫! 優(yōu)秀范文|法律文書|專利查詢|
            主站蜘蛛池模板: 日韩大片在线永久免费观看网站| 国产成AV人片久青草影院| 精品尤物国产尤物在线看| 日韩国产av一区二区三区精品| 高清免费毛片| 日韩在线视频网| 强开少妇嫩苞又嫩又紧九色| 99在线精品视频观看免费| 波多野结衣中文字幕久久| 亚洲人成在线观看网站不卡| 无套内射视频囯产| 国产精品人伦一区二区三| 亚洲黄色性视频| 国产高清视频一区二区三区| 国产伦码精品一区二区| 国产香蕉尹人综合在线观看| 太深太粗太爽太猛了视频| 国产精品白浆在线观看免费 | 国产精品福利视频导航| 国产精成人品日日拍夜夜| 太深太粗太爽太猛了视频| 久久被窝亚洲精品爽爽爽| 国产精品日韩av在线播放| 午夜一区二区三区视频| 成人影院视频免费观看| 亚洲国产天堂久久国产91| 2019久久久高清日本道| 日本边添边摸边做边爱喷水| 日韩国产av一区二区三区精品| 亚洲五月天一区二区三区| 国产亚洲精品成人aa片新蒲金| 中文字幕在线无码一区二区三区| 狂野欧美激情性xxxx| 免费看国产成年无码av| 国产精品人一区二区三区| 久久精品国产亚洲av麻豆小说| 女人扒开的小泬高潮喷小| 亚洲香蕉伊综合在人在线| 91在线国内在线播放老师| 国产亚洲国产精品二区| 麻豆国产va免费精品高清在线|