1 Reply Latest reply: Feb 11, 2014 11:22 AM by jun xia RSS

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

    Airnauts

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

       

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

       

      // 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

        • 1. Re: window.cep.process.createProcess - how to capture process stdout/stderr?
          jun xia Adobe Employee

          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.