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

app.system: Is there a way to retrieve the results, the stdout, of this command

Enthusiast ,
Apr 07, 2017 Apr 07, 2017

Copy link to clipboard

Copied

I ran the following JSX from a Mac OS Photoshop custom HTML extension panel

  • function RunSomeCli(Cmd){ 
  •   return(app.system(Cmd)); 
  •  
  • //Run some PHP and retrieve the results: 
  • RunSomeCLi("curl -A 'UserAgent' -d 'ThisParam=ThatValue' '[Path-To-Hosted-Php]'"); 
  • //Returns 0.  That's it. 
  •  
  • //Then ran a test whether app.system works at all with this curl to download a file 
  • RunSomeCli("curl -A 'UserAgent' -o '/[PathToLocalDestFile].txt' 'http://[PathToHostedFile].txt'"); 
  • //also Returns 0, but executes the download successfully. 

So the app.system works, and I'm able to run CLI commands, but thus far unable to retrieve stdout results.

TOPICS
Actions and scripting

Views

2.5K

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
Contributor ,
Apr 07, 2017 Apr 07, 2017

Copy link to clipboard

Copied

Run Your binaries from HTML panel as standard NodeJS chidprocesses. Leave that old mastodon .jsx for the unavoidable tasks.

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
Enthusiast ,
Apr 17, 2017 Apr 17, 2017

Copy link to clipboard

Copied

Yes, works great, but was curious if there might also be an option in the JSX/ExtendScript context.

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
Guest
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

LATEST

Please try this, from: Re: Change foreground color according to clipboard

function getSystemCommandStdout (command)

{

    var stdout = "";

    var tempFile = new File (Folder.temp + "/temp.txt");

    app.system (command + " > " + tempFile.fsName);

    if (tempFile.open ("r"))

    {

        stdout = tempFile.read ();

        tempFile.close ();

        tempFile.remove ();

    }

    return stdout;

}

var result = getSystemCommandStdout ("curl -A 'UserAgent' -d 'ThisParam=ThatValue' '[Path-To-Hosted-Php]'";

$.write (result);

HTH,

--Mikaeru

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