roystonmarshall
10-10-2011, 02:17 AM
Hi.
This is my first post, so please bear with me!.
I am writing some Javascript for some InDesign automation (shouldn't matter what for, but some background info). I have up to now been resorting to passing a script to Applescript, which then passed a shell command (via do script) to Terminal.
This works, but is limiting my script to Mac only.
I recently found I can open a socket, and send the PHP page my variables without leaving JavaScript..
Here is the code I am using with the Applescript combo:
function combinedErrorReport(errorText) //errorText is something like "Library not found"
{
myServerAddress = "http://automation.yappp.net/";
errorText = encodeURI(errorText);
myFullScriptString = "do shell script \"curl -0 "+ myServerAddress + "sendSrcError.php?e=" + errorText + "\"";
myForceError = app.doScript(myFullScriptString, ScriptLanguage.APPLESCRIPT_LANGUAGE);
}
and this is what I want to use using a javascript socket...
function combinedErrorReportWithSocket(errorText) //errorText is something like "Library not found"
{
myServerAddress = "automation.yappp.net:80";
errorText = encodeURI(errorText);
conn = new Socket();
conn.open(myServerAddress);
conn.write("GET /sendSrcError.php?e=" + errorText+"\ HTTP/1.0\n\n");
reply = conn.read(999999);
conn.close;
}
The socket option simply does nothing. It opens the connection, but doesn't pass anything to the PHP.
Anyone have any ideas?
Cheers
Roy
This is my first post, so please bear with me!.
I am writing some Javascript for some InDesign automation (shouldn't matter what for, but some background info). I have up to now been resorting to passing a script to Applescript, which then passed a shell command (via do script) to Terminal.
This works, but is limiting my script to Mac only.
I recently found I can open a socket, and send the PHP page my variables without leaving JavaScript..
Here is the code I am using with the Applescript combo:
function combinedErrorReport(errorText) //errorText is something like "Library not found"
{
myServerAddress = "http://automation.yappp.net/";
errorText = encodeURI(errorText);
myFullScriptString = "do shell script \"curl -0 "+ myServerAddress + "sendSrcError.php?e=" + errorText + "\"";
myForceError = app.doScript(myFullScriptString, ScriptLanguage.APPLESCRIPT_LANGUAGE);
}
and this is what I want to use using a javascript socket...
function combinedErrorReportWithSocket(errorText) //errorText is something like "Library not found"
{
myServerAddress = "automation.yappp.net:80";
errorText = encodeURI(errorText);
conn = new Socket();
conn.open(myServerAddress);
conn.write("GET /sendSrcError.php?e=" + errorText+"\ HTTP/1.0\n\n");
reply = conn.read(999999);
conn.close;
}
The socket option simply does nothing. It opens the connection, but doesn't pass anything to the PHP.
Anyone have any ideas?
Cheers
Roy