0
Trouble getting curl applescript to execute in JSX
Community Expert
,
/t5/photoshop-ecosystem-discussions/trouble-getting-curl-applescript-to-execute-in-jsx/td-p/13764940
May 01, 2023
May 01, 2023
Copy link to clipboard
Copied
Hi all,
I am trying to curl images down from a website for a photoshop JSX application. If I type the following applescript into a .applescript file, then it works fine. However, I am throwing my 10 seconds elapsed error if I try to run the getMacImage function below. If I inspect the dl.app script that was created, it works fine. I've also tried saving as dl.applescript and it throws an error. The AS is here:
do shell script "curl -L -o '/Users/MyUserName/Desktop/test.jpg' 'https://www.google.co.in/intl/en_com/images/srpr/logo1w.png'"
Here is my jsx code:
var getMacImage = function(exporturl, assetFolderPath, fileName) {
try {
var ff = File(assetFolderPath + '/' + fileName);
if (!ff.exists) {
var curlCommand = "\"curl -L -o '" + ff.fsName + "' " + "'" + exporturl + "'";
var asCode = 'do shell script ' + curlCommand + '"';
var vbsf = new File(Folder.desktop + "/dl.applescript");
vbsf.open('w');
vbsf.write(asCode);
vbsf.close();
//alert(asCode);
vbsf.execute();
}
var c = 0;
while(!ff.exists) {
$.sleep(1);
c++;
if (c > 1000) {
throw new Error("More than 10 seconds to download image");
}
}
return ff;
}
catch(e) {
throw new Error("Error downloading asset from " + exporturl + ". " + e);
}
};
var unitTest = function() {
var afp = Folder.desktop.fsName;
var imgp = "https://www.google.co.in/intl/en_com/images/srpr/logo1w.png";
try {
var f = getMacImage(imgp, afp, "test1.jpg");
} catch(e) {
alert(e);
}
alert(f.exists);
}
unitTest();
TOPICS
Actions and scripting
,
macOS
,
SDK
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explore related tutorials & articles
brian_p_dts
AUTHOR
Community Expert
,
LATEST
/t5/photoshop-ecosystem-discussions/trouble-getting-curl-applescript-to-execute-in-jsx/m-p/13868950#M738881
Jun 15, 2023
Jun 15, 2023
Copy link to clipboard
Copied
Bumping this back up to see if anyone has had issues executing Applescript from JSX routines lately. This code used to work, and the ASCode string works when I run it in the Applescript debugger. Maybe a permissions issue?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

