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

Include Remote file in Windows

Advocate ,
Oct 03, 2018 Oct 03, 2018

Copy link to clipboard

Copied

I start from this discussion

use photoshop cc 2018

https://forums.adobe.com/thread/2537681

I thank Trevor for his help

I need to use .js or. jsx remotely

With mac everything works correctly

in windows it does not work

I would like to find a solution for this.

TOPICS
Actions and scripting

Views

459

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
Guru ,
Oct 04, 2018 Oct 04, 2018

Copy link to clipboard

Copied

Hi I moved to Photoshop Scripting which is the correct place for the thread.

The difference between Id doScript and Ps system is the doScript does execute visual basic and applescipt whereas system executes shell. doScript returns a result and system doesn't so it needs piping.

Below is not enterprise fail-safe stuff, that cost money.

Enjoy

// Downloads and executes a remote script in Photoshop

// See https://forums.adobe.com/thread/2537681 and https://forums.adobe.com/thread/2542822

// By Trevor http://creative-scripts.com

if (app.name !== 'Adobe Photoshop') {

    alert('Crash, for Adobe Photoshop only!');

}

var remoteCode = 'https://gist.githubusercontent.com/Trevor-/4158c50c876817b6a96336ce23867485/raw';

// this function is nicked from // https: //forums.adobe.com/thread/2364797

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 shell = $.os[0] === 'M' ? "curl 'remoteCode'" /* Mac */ :

    'powershell.exe  -windowstyle hidden "Invoke-WebRequest -Uri remoteCode | Select-Object -ExpandProperty Content"'; /* Windows */

var result = getSystemCommandStdout(shell.replace("remoteCode", remoteCode));

// Set some local vars for the remote script

var varFromLocal1 = 'Hello';

var varFromLocal2 = 'World';

// Run the "remote" script

eval(result);

// Share functions and vars

blah(varFromRemote, 'bar');

https://forums.adobe.com/thread/2542822

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
Guru ,
Oct 04, 2018 Oct 04, 2018

Copy link to clipboard

Copied

P.s. from powershell 5 one can use curl instead of Invoke-WebRequest -Uri

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
Advocate ,
Oct 05, 2018 Oct 05, 2018

Copy link to clipboard

Copied

LATEST

Trevor thanks for the help

2 questions:

1) this script as I understand it is good for both windows and mac.

2) you can put a warning if internet connection is missing.

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