Skip navigation
Currently Being Moderated

window.cep.process.createProcess - how to capture process stdout/stderr?

Feb 11, 2014 2:00 AM

I am using following code to execute process and capture stderr/stdout:

 

proc = window.cep.process.createProcess('/path/to/nodejs','/path/to/script.j s');

 

// proc.data is a PID

 

window.cep.process.stdout(proc.data,function(line){

    console.log(line);

});

 

window.cep.process.stderr(proc.data,function(line){

   console.log(line);

});

 

And here is my script.js:

 

console.log('abcdef');

console.log('12345');

console.log('gghhtt');

 

For some reason only the first line ('abcdef') is printed by stdout handler (handler is called only once)... Next lines are ignored and callback is never called again. What I am doing wrong?

 

Adobe Photoshop Version: 14.2 (14.2 20131211.r.515 2013/12/11:23:00:00) x64

Operating System: Mac OS 10.9.1

 
Replies
  • Currently Being Moderated
    Feb 11, 2014 11:22 AM   in reply to Airnauts

    There is nothing wrong in your code. This is a limitation of cep.process.stdout/stderr which is targeting to capture one time of stdout/stderr output. For now, two workarounds are suggested as the following.

     

    a. Embed cep.process.stdout/stderr, like the code below

     

    window.cep.process.stdout(proc.data,function(line){

        console.log(line);

        window.cep.process.stdout(proc.data,function(line2){

            console.log(line2);   

            window.cep.process.stdout(proc.data,function(line3){

                console.log(line3);

            });

        });

    });

     

    b. Join all stdout output as one, like

    var str1 = 'abcdef';

    var str2 = '12345';

    var str3 = 'gghhtt';

    console.log(str1 + str2 + str3);

     

    Besides, the good news is since CEP5, nodejs is integrated into CEP and your script could be executed in Html engine of CEP directly. My guess is Photoshop 15.0 will probably pick up CEP5 to involve the benefit in. Kindly let me know if you need more information.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points