Running pmcmd from java

核能气质少年 提交于 2020-01-16 15:16:08

问题


I am trying to run pmcmd and pass arguments from java. This is my code :

String cmd="C:\\Informatica\\9.6.1\\clients\\PowerCenterClient\\CommandLineUtilities\\PC\\server\\bin\\pmcmd.exe";
    final Process cmdProcess;

    cmdProcess = Runtime.getRuntime().exec(new String[]{cmd,"connect -sv IS_NAME -d DOMAIN_NAME -u USER -p PWD"});
    cmdProcess.getOutputStream().close();

The problem is I am not able to get the desired output. I get the following error:

ERROR: Unknown command [connect]

When I try the same command on the command line, it works.

pmcmd>connect -sv IS_NAME -d DOMAIN_NAME -u USER -p PWD

The output:

Connected to Integration Service:[IS_NAME].

Can anyone tell what mistake I am doing?


回答1:


(adding my comment as an answer, after it worked according to the OP)

Your command line example suggests that the connect -sv ... is issued within the pmcmd process, and not provided as an argument.

So you should probably send that to the process' STDIN (accessed by cmdProcess.getOutputStream()) instead of passing as argument to the call.




回答2:


pmcmd works in two modes, command line and interactive. connect command works in interactive mode only.

When invoking from java, you are using command line mode, and do not need to connect first. You can directly invoke the command you intend to run (ex. startWorkflow) and provide the connection parameters with that command like below:

pmcmd startworkflow -sv MyIntService -d MyDomain -u seller3 -p jackson ‑f SalesEast wf_SalesAvg

More details here.




回答3:


I had to issue a command within the pmcmd process. So I modified my code and it works :

                String cmd="C:\\Informatica\\9.6.1\\clients\\PowerCenterClient\\CommandLineUtilities\\PC\\server\\bin\\pmcmd.exe";
                final Process cmdProcess;

                cmdProcess = Runtime.getRuntime().exec(new String[]{cmd,""});
                OutputStream out = cmdProcess.getOutputStream();
                out.write("connect  -sv IS_NAME -d DOMAIN_NAME -u USER -p PWD".getBytes());
                out.close;


来源:https://stackoverflow.com/questions/46592292/running-pmcmd-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!