为了账号安全,请及时绑定邮箱和手机立即绑定

运行 autosys 批处理作业并在 java 中检查其状态

运行 autosys 批处理作业并在 java 中检查其状态

鸿蒙传说 2021-08-06 11:19:07
我需要运行 autosys 批处理作业,然后检查其状态,直到其状态更改为 SU。我编写了以下代码,但它给了我以下异常:CreateProcess error=2, The system cannot find the file specified代码:try {            String[] cmds = {                    "C:\\Folder_Path\\plink.exe -ssh username@Server -pw Password",                    "sendevent -E FORCE_STARTJOB -j job-name"};            Runtime r = Runtime.getRuntime();            Process p = r.exec(cmds);            InputStream std = p.getInputStream ();            OutputStream out = p.getOutputStream ();            InputStream err = p.getErrorStream ();            Thread.sleep (5000);            int value = 0;            String output = "";            if (std.available () > 0) {                System.out.println ("STD:");                value = std.read ();                //System.out.print ((char) value);                while (std.available () > 0) {                    value = std.read ();                    output+=(char) value;                }            }            if (err.available () > 0) {                System.out.println ("ERR:");                value = err.read ();                //System.out.print ((char) value);                while (err.available () > 0) {                    value = err.read ();                    output+=(char) value;                }            }            System.out.print (output);            p.destroy ();        }        catch (Exception e) {            e.printStackTrace ();        }
查看完整描述

1 回答

?
慕后森

TA贡献1802条经验 获得超5个赞

你的 cmd 应该是:

String[] cmds = {"C:\\Folder_Path\\plink.exe", "-ssh", "username@Server", "-pw", "Password", "sendevent", "-E", "FORCE_STARTJOB", "-j", "job-name"};

第一个参数是可执行文件名。使用您的 cmd,它会给出错误,因为它无法找到 "C:\Folder_Path\plink.exe -ssh username@Server -pw Password" 。
你的 exe 是 C:\Folder_Path\plink.exe,所以它应该是第一个参数。


查看完整回答
反对 回复 2021-08-06
  • 1 回答
  • 0 关注
  • 166 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信