0

I am using java process builder to start python process with one flag and with one argument as shown below. But i don't see any exception nor process starts up.

Command i want to run is

python oc_db5.py -c input.json

location of file oc_db5.py is

/opt/jvision/grpc/gui

My code is shown below

    processBuilder = new ProcessBuilder(

            Arrays.asList(
                    "python",
                    "oc_db5.py",
                    "-c",
                    "input.json"));

    processBuilder.directory(new File("/opt/jvision/grpc/gui"));

    processBuilder.start();

    logger.info("Process started ..." + new Date());

    int count = 0;
    BufferedReader br = new BufferedReader(new InputStreamReader(
            process.getInputStream()));

    while ((lineData = br.readLine()) != null) {

        System.out.println("line: " + ++count + " " + lineData);
        logger.info("line: " + ++count + " " + lineData);
    }
    process.waitFor();
    process.getErrorStream();
    process.waitFor();

    process.exitValue();

I can see that log file contains entry "process start..." but i don't really see that process is started. Wondering what i am missing.

1 Answer 1

1

Can you check if python is in your PATH? I have similar problem with custom command long long time ago. You can use absolute path to try it :). You can also check you enviromental variables via

Map env = System.getenv();

If you are using Linux you can start process like "sleep 1000" then check it is present in system process table via "ps aux | grep sleep" or something like it :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.