Copy link to clipboard
Copied
What equivalent "callSystem" for Illustrator
because callSystem for after effects
Copy link to clipboard
Copied
What does "callSystem" do?
Copy link to clipboard
Copied
its make jsx cde that veirify key with gumroad:
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?
Copy link to clipboard
Copied
its make jsx cde that veirify key with gumroad:
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.
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...
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.
Copy link to clipboard
Copied
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++;
}
}
}
}