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

How to execute the curl command inside JSX script running in InDesign?

Participant ,
Jun 03, 2022 Jun 03, 2022

Hi All,

 

I have curl command. For example, curl google.com . Now, I want the command to execute inside JSX script and the script is already running in InDesign application.

 

I tried to using app.system("curl google.com"). It doesn't work.

Please give any alternate idea to executing this.

 

Thanks.

 

TOPICS
How to , Scripting
1.2K
Translate
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 , Jun 04, 2022 Jun 04, 2022

Hi @AD4003 , Here’s an OSX example, gets my local weather:

 

 

var tp = "~/Desktop/NewburyportWeather.txt"


var nbptWeather = 'tell application id "com.adobe.indesign"\rset nw to do shell script "curl https://api.weather.gov/gridpoints/BOX/73,98/forecast/hourly"\rdo shell script "echo " & quoted form of nw & " > ~/Desktop/NewburyportWeather.txt"\rend tell';
$.writeln( nbptWeather.toString());

app.doScript(nbptWeather, ScriptLanguage.applescriptLanguage);
var myWeather = readFile(tp)
alert(myWe
...
Translate
Community Expert ,
Jun 03, 2022 Jun 03, 2022

Hi @AD4003,

Not much is available nattvely in ExtendScript. See the following discussion for details

https://community.adobe.com/t5/indesign-discussions/any-way-to-access-static-weblinks-amazon-s3-thro...

You could also try using Applescript on a MAC and VBScript on WIN via the app.doScript method.

-Manan

Translate
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
Community Expert ,
Jun 04, 2022 Jun 04, 2022

"I tried to using app.system("curl google.com"). It doesn't work."

 

That should work with PhotoShop on MacOS. Never tried on Windows 10.

InDesign does not have the system() method on app.

 

Look into this thread:

https://community.adobe.com/t5/indesign-discussions/include-remote-js-file-in-script-file-and-use-it...

 

Let us know how it goes.

 

Also look into Marc Autret's framework IdExtenso:

https://github.com/indiscripts/IdExtenso

https://github.com/indiscripts/IdExtenso/blob/master/etc/$$.Web.jsxlib

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

Translate
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
Community Expert ,
Jun 04, 2022 Jun 04, 2022
LATEST

Hi @AD4003 , Here’s an OSX example, gets my local weather:

 

 

var tp = "~/Desktop/NewburyportWeather.txt"


var nbptWeather = 'tell application id "com.adobe.indesign"\rset nw to do shell script "curl https://api.weather.gov/gridpoints/BOX/73,98/forecast/hourly"\rdo shell script "echo " & quoted form of nw & " > ~/Desktop/NewburyportWeather.txt"\rend tell';
$.writeln( nbptWeather.toString());

app.doScript(nbptWeather, ScriptLanguage.applescriptLanguage);
var myWeather = readFile(tp)
alert(myWeather)

function readFile(p) {
	var f = new File(p);
	f.open("r");  
	var x = f.read();  
	f.close();
	return x; //returns the text
}

 

 

Translate
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