Executing PMCMD command from JAVA Client

1.5k views Asked by At

I want to start workflow from JAVA. I connect to informatica server using SSH and execute the command pmcmd to start workflow

JSch js = new JSch();
        Session s = js.getSession("username", "host", 22);
        s.setPassword("password");
        Properties config = new Properties();
        config.put("StrictHostKeyChecking", "no");
        s.setConfig(config);
        s.connect();

        Channel c = s.openChannel("exec");
        ChannelExec ce = (ChannelExec) c;

        ce.setCommand("pmcmd startworkflow -sv integrationservice -d Domain_dwhetl -u user -p pass-usd hq -f dvl wf_test");
        //ce.setCommand("find -name PMCMD");
        ce.setErrStream(System.err);

        ce.connect();

        BufferedReader reader = new BufferedReader(new InputStreamReader(ce.getInputStream()));
        String line;
        while ((line = reader.readLine()) != null) {
          System.out.println(line);
        }

        ce.disconnect();
        s.disconnect();

        System.out.println("Exit code: " + ce.getExitStatus());

When I run this I'm getting the error : bash: pmcmd: command not found. If I add path to pmcmd.exe:

  ce.setCommand("/PMRootDir/pmcmd startworkflow -sv integrationservice -d Domain_dwhetl -u user -p pass-usd hq -f dvl wf_test");

I get the error: /PMRootDir/pmcmd: error while loading shared libraries: libpmasrt.so: cannot open shared object file: No such file or directory

But when I run those commands in informatica server directly the workflow starts successfully.

Cand anyone help to solve this problem?

Thank you!

3

There are 3 answers

0
Samik On

You have set the PATH to where Informatica is installed, or more specifically the directory the pmcmd executable is present. Add the export command before calling pmcmd.

export PATH=<path Infa installation directory>:$PATH;
0
Meruert On

@Samik, Thank you! I've added this

"export INFA_HOME=<path Infa installation directory>; " +
                    "export PM_HOME=<path Infa installation directory>; " +
                    "export PATH=$PATH:<path Infa installation directory>/server/bin; " +
                    "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path Infa installation directory>/server/bin; "

and it worked

0
vikas yadav On

You need to set Environment Variable Path Example

export PATH=$PATH:/pwc/Informatica/10.2/server/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/pwc/Informatica/10.2/server/bi