• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

using CLI from extendscript

New Here ,
Apr 17, 2019 Apr 17, 2019

Copy link to clipboard

Copied

Hello,

I've written a python library that'd be useful in a PPro panel. If I turn this library into a command line tool, would I be able to access it via extendscript?

I assume a plug-in written in C could access the command line otherwise, but I'm unable to find any info on how to start writing plugins for PPro.

Any help would be appreciated. Thank you.

TOPICS
SDK

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 18, 2019 Apr 18, 2019

You can access the command line from PPRO through Node.js child process exec and execSync. You'll need a CEP panel with Node.js enabled, and then you can run commands like this:

// async method

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

exec('run myCommand', {encoding: "UTF-8"}, function (err, stdout, stderr) {

    console.log(stdout);

    console.log(stderr);

    console.log(err);

});

// or

// sync method

var execSync = require('child_process').execSync;

var res = execSync('run myCommand', {encoding: 'UTF-

...

Votes

Translate

Translate
Community Expert ,
Apr 18, 2019 Apr 18, 2019

Copy link to clipboard

Copied

You can access the command line from PPRO through Node.js child process exec and execSync. You'll need a CEP panel with Node.js enabled, and then you can run commands like this:

// async method

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

exec('run myCommand', {encoding: "UTF-8"}, function (err, stdout, stderr) {

    console.log(stdout);

    console.log(stderr);

    console.log(err);

});

// or

// sync method

var execSync = require('child_process').execSync;

var res = execSync('run myCommand', {encoding: 'UTF-8'});

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 21, 2019 Apr 21, 2019

Copy link to clipboard

Copied

LATEST

That would definitely work.

Actually, node.js usage is not required; CEP provides access to command lines. [Unlike AE's ExtendScript API, PPro's ExtendScript API offers no direct command line access.]

Here's a snippet of JavaScript that has the user choose a .mogrt, then builds a command line string invoking a .py script within the panel's package, and passing it the selected file path.

function processMoGRT (){

   var csInterface = new CSInterface();

   var OSVersion  = csInterface.getOSInformation();

   var filetypes = new Array();

  filetypes[0] = "mogrt";

   var result = window.cep.fs.showOpenDialog(false,false,"Select a .mogrt file", "~/Desktop",filetypes);

   var mogrtPath = result.data[0];

   var extPath  = csInterface.getSystemPath(SystemPath.EXTENSION);

  

   var sep  = "/";


   if (OSVersion.indexOf("Windows") > 0){

  sep = "\\\\";  

   }


   var mogrtParentPath = mogrtPath.substring(0, mogrtPath.lastIndexOf(sep));


   var pyPath = extPath + sep + 'Foiltop.py';


   var processResult = window.cep.process.createProcess("usr/bin/python", pyPath, mogrtPath);

  

   if (OSVersion.indexOf("Windows") >=0){

  window.cep.process.createProcess("C:\\Windows\\explorer.exe", mogrtParentPath);

   } else {

  window.cep.process.createProcess("/usr/bin/open", mogrtParentPath);

   }

   var resultFileName = mogrtParentPath + sep + "Foiltop_results.txt";

  

   var resultFileContents = window.cep.fs.readFile(resultFileName);//, cep.encoding.Base64);

  

   if (0 === result.err) {

   alert(resultFileContents.data);

   } else {

   alert("Failed to read results file.");

   }


  

  


}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines