0

while trying to execute following command using exec

java -cp %SIKULI_HOME%\sikuli-script.jar org.python.util.jython E:\automation.sikuli\automation.py "a,b,c" 

am getting following error

var exec = require('child_process').execFile;

postreq.params prints values as a,b,c.i want to pass this with \automation.py "a,b,c" i dodnt know how to pass with below one

 exec('java -cp %SIKULI_HOME%\sikuli-script.jar org.python.util.jython E:\automation.sikuli\automation.py postreq.params', function (err, data) {
    console.log(err);
    console.log(data);
    console.log("Sikuli execution started")
    //  res.end(data);
  });

error

{ [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }

below command is working properly using cmd

java -cp %SIKULI_HOME%\sikuli-script.jar org.python.util.jython E:\automation.sikuli\automation.py "a,b,c"

2 Answers 2

1

The way you explain your problem, postreq.params seems to be a JavaScript variable. If so, this is what you should exec:

var exec = require("child_process").exec;
exec('java -cp %SIKULI_HOME%\sikuli-script.jar org.python.util.jython E:\automation.sikuli\automation.py "' +  postreq.params + '"', function (err, data) {

I'm not a Windows guy so I'm not positive that %SIKULI_HOME% will be expanded like you want. If not, then using process.env.HOMEPATH like Phoenix suggested in a comment should do the trick:

exec('java -cp ' + proces.env.HOMEPATH + '\sikuli-script.jar org.python.util.jython E:\automation.sikuli\automation.py "' +  postreq.params + '"', function (err, data) {
Sign up to request clarification or add additional context in comments.

Comments

0

The first argument to execFile is the file to run. You are passing a full set of arguments. Try this:

exec('java',  ['-cp', '%SIKULI_HOME%\sikuli-script.jar',
    'org.python.util.jython', 'E:\automation.sikuli\automation.py',
    'postreq.params'], function (err, data) {

I'm not sure if it will expand %SIKULI_HOME% since I'm not super familiar with Windows.

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.