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

What  equivalent  "callSystem" for Illustrator

Explorer ,
Dec 03, 2023 Dec 03, 2023

Copy link to clipboard

Copied

What  equivalent  "callSystem" for Illustrator

because callSystem for after effects

TOPICS
Bug , Experiment , Feature request , How-to , Performance , Scripting , SDK , Tools

Views

537

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
Community Expert ,
Dec 03, 2023 Dec 03, 2023

Copy link to clipboard

Copied

What does "callSystem" do?

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
Explorer ,
Dec 03, 2023 Dec 03, 2023

Copy link to clipboard

Copied

its make jsx cde that veirify key with gumroad:

// super simple script

var scriptName = "Testing";

var gumroadRegFolder = Folder("~/Documents/Gumroad Reg");
if(!gumroadRegFolder.exists) {
    gumroadRegFolder.create();
}

var registrationWindow = new Window("palette", "Gumroad Registration");
var registrationWindow = new Window("dialog", "Gumroad Registration");
var regInput = registrationWindow.add("edittext", undefined, "Registration Code Goes In Here");
var buttonGroup = registrationWindow.add("group", undefined, "");
buttonGroup.orientation = "row";
var cancelButton = buttonGroup.add("button", undefined, "Cancel");
var saveButton = buttonGroup.add("button", undefined, "Save");

var window = new Window("palette", "Gumroad Test", undefined);
window.orientation = "column";
var text = window.add("statictext", undefined, "You've successfully gotten past Gumroad registration");
var button = window.add("button", undefined, "Button");

var gumroadCheckFile = File("~/Documents/Gumroad Reg/"+scriptName+".json");
if(!gumroadCheckFile.exists) {
    registrationWindow.center();
    registrationWindow.show();
} else {
    gumroadCheckFile.open("r");
    var regInfo = gumroadCheckFile.read();
    gumroadCheckFile.close();
    verifyRegistration(regInfo);
}

cancelButton.onClick = function() {
    registrationWindow.hide();
}

saveButton.onClick = function() {
    if(regInput.text != "" || regInput.text != "Registration Code Goes In Here") {
        verifyRegistration(regInput.text);
    }
}


function verifyRegistration(regString) {
    var test = system.callSystem('curl https://api.gumroad.com/v2/licenses/verify -d "product_permalink=testproduct" -d "license_key=' + regString + '" -d "product_id=RiaDI==" -X POST');
    // var test = system.callSystem('curl https://api.gumroad.com/v2/licenses/verify -d "product_permalink=gumroadreg" -d "license_key='+regString+'" -d "increment_uses_count=false" -X POST');

var returnData = JSON.parse(test.slice(test.indexOf("{")-1, test.length));

alert(JSON.stringify(returnData));

if(returnData["success"]) {
    gumroadCheckFile.open("w");
    gumroadCheckFile.write(regString);
    gumroadCheckFile.close();

   
    window.center();
    window.show();
    registrationWindow.hide();
} else {
    alert("Not a valid registration code, please check and try again");
    return false;
}

}.

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
Guide ,
Dec 03, 2023 Dec 03, 2023

Copy link to clipboard

Copied

system.callSystem() in After Effects seems to run a command line, as if run in the system's command line interface.  I have not seen such thing in Illustrator scripting.  Instead, what are you trying to get the command line to do? 

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
Explorer ,
Dec 03, 2023 Dec 03, 2023

Copy link to clipboard

Copied

its make jsx cde that veirify key with gumroad:

// super simple script

var scriptName = "Testing";

var gumroadRegFolder = Folder("~/Documents/Gumroad Reg");
if(!gumroadRegFolder.exists) {
    gumroadRegFolder.create();
}

var registrationWindow = new Window("palette", "Gumroad Registration");
var registrationWindow = new Window("dialog", "Gumroad Registration");
var regInput = registrationWindow.add("edittext", undefined, "Registration Code Goes In Here");
var buttonGroup = registrationWindow.add("group", undefined, "");
buttonGroup.orientation = "row";
var cancelButton = buttonGroup.add("button", undefined, "Cancel");
var saveButton = buttonGroup.add("button", undefined, "Save");

var window = new Window("palette", "Gumroad Test", undefined);
window.orientation = "column";
var text = window.add("statictext", undefined, "You've successfully gotten past Gumroad registration");
var button = window.add("button", undefined, "Button");

var gumroadCheckFile = File("~/Documents/Gumroad Reg/"+scriptName+".json");
if(!gumroadCheckFile.exists) {
    registrationWindow.center();
    registrationWindow.show();
} else {
    gumroadCheckFile.open("r");
    var regInfo = gumroadCheckFile.read();
    gumroadCheckFile.close();
    verifyRegistration(regInfo);
}

cancelButton.onClick = function() {
    registrationWindow.hide();
}

saveButton.onClick = function() {
    if(regInput.text != "" || regInput.text != "Registration Code Goes In Here") {
        verifyRegistration(regInput.text);
    }
}


function verifyRegistration(regString) {
    var test = system.callSystem('curl https://api.gumroad.com/v2/licenses/verify -d "product_permalink=testproduct" -d "license_key=' + regString + '" -d "product_id=RiaDI==" -X POST');
    // var test = system.callSystem('curl https://api.gumroad.com/v2/licenses/verify -d "product_permalink=gumroadreg" -d "license_key='+regString+'" -d "increment_uses_count=false" -X POST');

var returnData = JSON.parse(test.slice(test.indexOf("{")-1, test.length));

alert(JSON.stringify(returnData));

if(returnData["success"]) {
    gumroadCheckFile.open("w");
    gumroadCheckFile.write(regString);
    gumroadCheckFile.close();

   
    window.center();
    window.show();
    registrationWindow.hide();
} else {
    alert("Not a valid registration code, please check and try again");
    return false;
}

}

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 ,
Dec 04, 2023 Dec 04, 2023

Copy link to clipboard

Copied

There is no equivalent. The best you can do is write a shell / bash script onto a local file and run it via File.execute() in scripting, or ignore scripting altogether and handle it from a CEP plugin via NodeJS and child_process.

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
Community Expert ,
Dec 03, 2023 Dec 03, 2023

Copy link to clipboard

Copied

Illustrator’s ExtendScript does not have commands for executing shell scripts or web access.

 

Therefore, other technologies are required to perform web access on behalf of Illustrator. For example, the following...

  • Ordering to After Effects/Photoshop/Bridge, etc. using BridgeTalk
  • Prepare a main process with web access functionality in CEP/AppleScript/VBS/Electron, etc.
  • Create a single-function app with AppleScript/AutoHotkey, etc. that only verifies licenses with Gumroad, and execute it with File.open()

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
Community Expert ,
Dec 04, 2023 Dec 04, 2023

Copy link to clipboard

Copied

there is a workaround for executing shell scripts, but its not exactly elegant.

 

on mac, you can store a generic applescript app that only executes a shell script at a certain location. then you can use your jsx code to write the shell script text to that file, then execute the applescript app.

 

It can be done on windows as well. I know because i did it once, but unfortunately its been long enough that i have no idea how i did it. something about writing to a .bat file that executes some powershell code or something.

 

then youd just need your shell script code to save the results of the "curl" command to a file that can be read by the jsx.

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
Community Expert ,
Dec 26, 2023 Dec 26, 2023

Copy link to clipboard

Copied

LATEST

hey everybody. my sincere apologies for the delay. i got busy, and then i forgot.

 

Heres the workaround code to make a request to some website from illustrator (or theoretically, any other adobe software that doesnt offer a native solution). Warning, this was purpose built for my purposes quite a while ago and i havent bothered updating it since its working for me, so it likely needs tweaks and is definitely pretty messy. and it might have some dependencies from my own utilities, but those are generic and easy.

 

for my needs, i have a single URL and i just paste in an identifier (order number or something) to the end of the URL and that gives me the data i need. If you are accessing data from some public API that requires credentials to be sent with the payload, im not exactly sure how to manage that. but hopefully this mess helps point someone in the right direction.

 

//curl data from a specified url and return the data as an anonymous object
function curlData ( url, arg )
{
	var result, status = "empty";;
	var htmlRegex = /<html>/gmi;

	var scriptText,
		scriptFile,
		executor,
		killExecutor;



	url = url + arg;


	//variables for the local data stuff
	var documentsPath = "path/to/documents/folder/"
	var curlDataPath = documentsPath + "curlData/"
	var curlDataFolder = new Folder( curlDataPath );
	if ( !curlDataFolder.exists )
	{
		curlDataFolder.create();
	}
	var localDataFile = File( curlDataPath + "curlData.txt" );


	//clear out the local data file..
	//make sure we always start with an empty string
	localDataFile.open( "w" );
	localDataFile.write( "" );
	localDataFile.close();


	if ( $.os.match( "Windows" ) )
	{
		//write the bat file that will be
		//used to execute the vbs script
		writeVbsFile();

		//define the executor script
		//cscript.exe runs the .vbs file as though the CL is being used
		scriptText = "cscript.exe \"";

		//path to vbs script
		scriptText += curlDataPath + "socket_xhttpRequest.vbs\"";

		//vbs argument 1 = url
		scriptText += " \"" + url + "\" \"";

		//vbs argument 2 = path to curlData.txt file
		scriptText += curlDataPath + "curlData.txt";

		scriptFile = File( curlDataPath + "batFile.bat" );
		writeScriptFile( scriptFile, scriptText )

		executor = scriptFile;
	}
	else
	{
		scriptText = [
			"do shell script ",
			"\"curl \\\"" + url,
			"\\\" > \\\"",
			curlDataPath + "curlData.txt" + "\\\"\""
		].join( "" );

		/

		scriptFile = File( curlDataPath + "curl_from_illustrator.scpt" );
		writeScriptFile( scriptFile, scriptText );
		executor = File( resourcePath + "curl_from_illustrator.app" );
		var localExecutor = File( documentsPath + "curlData/curl_from_illustrator.app" );
		if ( localExecutor.exists )
		{
	
			executor = localExecutor;
		}
	}


	var maxExecutorCalls = 5;
	var currentExecutorCalls = 0;

	var checkDelay = 200;
	var numberOfChecks = 200;
	var totalChecks = 0;

	var parseFailResults = 0;

	do
	{
		totalChecks = 0;
		//go get the data

		executor.execute();


		//check the data
		for ( var a = 0; a < numberOfChecks && status !== "valid"; a++ )
		{
			if ( status != "valid" )
			{
				checkData()
				totalChecks++;
			}
			else if ( status === "html" )
			{
				break;
			}
			$.sleep( checkDelay );
		}




	}
	while ( status !== "valid" && status !== "html" && currentExecutorCalls < maxExecutorCalls );


	//validate
	if ( status === "html" || ( status === "empty" && parseFailResults.length ) )
	{
		alert( "The request to \"" + url + arg + "\" returned invalid data for " + arg );
	}

	return result;



	function readDataFile ()
	{
		var file = localDataFile;
		file.open( "r" );
		var contents = file.read();
		file.close();

		return contents;
	}

	function writeScriptFile ( file, txt )
	{
		file.open( "w" );
		file.write( txt );
		file.close();
	}

	function writeVbsFile ()
	{

		//go to the network and copy the contents of the
		//socket_xhttpRequest.vbs file
		//this allows me to manage updates by updating a
		//single central file, but each person will be executing
		//their own copy, which should avoid someone being denied
		//access because another person is already executing the file?

		//central file
		var srcFile = File( dataPath + "socket_xhttpRequest.vbs" );

		//local file
		var destFile = File( curlDataPath + "socket_xhttpRequest.vbs" );

		//read the source file's contents
		srcFile.open( "r" );
		var srcContents = srcFile.read();
		srcFile.close();

		//write the contents to the local file
		writeDatabase( destFile, srcContents );
	}

	function checkData ()
	{
		var contents = readDataFile();
		if ( contents === "" )
		{
			status = "empty";
		}
		else if ( contents.match( htmlRegex ) )
		{
			status = "html";
		}
		else
		{
			try
			{
				result = JSON.parse( contents );
				status = "valid";
			}
			catch ( e )
			{
				status = "parseFail";
				parseFailResults++;
			}
		}
	}



}

  

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