i have a javascript that runs on my website. is it possible to pass this variable to an idle applescript running on the same computer?? if so how?? if not, well…
thanks
i have a javascript that runs on my website. is it possible to pass this variable to an idle applescript running on the same computer?? if so how?? if not, well…
thanks
You might be able to have the JS write the variable to a file and then have the AppleScript read it.
i’ve heard that it is possible to write cgi scripts with applescript…
theoretically you could then set the value of some element in javascript and use html method to get/post…applescript should be able to read the http parameters just like ordinary parameters…
i’d be very interested in seeing if it could be done…
Sure, you can do that. I use a similar process on our intranet
only I use an HTML form to post the users request. The CGI script
should be saved as an application. The user hits the CGI script
via Web Sharing so the form should be set up to hit that Mac’s IP
and include the path to the CGI. e.g. if your IP=“000.00.000.00”
and a CGI script named “MyCGI.cgi” is in a folder named “cgi-bin”,
within your ‘Web Shared’ folder, then the HTML for your form would
look like:
<FORM ACTION="http://000.00.000.00/cgi-bin/MyCGI.cgi" METHOD="POST">
<INPUT TYPE="TEXT" NAME="search_string" VALUE=""><input TYPE="submit" VALUE="Find">
</FORM>
The following script will process text submitted by the user, in this case via a text entry
field but could be a drop-down menu, or javascript parameter. In this CGI I just pass back
the text the user sent, in a very simplistic web display. You could do just about anything,
like in my instance I have our Customer Service Dept. hit a script like this to find the
location of a file - the script searches thru some text files and when it finds a match
it returns HTML, with a link to the JPEG file they are looking for.
The CGI script for the form above would look like this:
on handle CGI request with posted data Posted_Data from client IP address client_ip_address
set Form_Data to parse CGI arguments Posted_Data without combining duplicates
try
set order_number to CGI field "search_string" from Form_Data as string--try to get the data the user sent
return "<html>
<body>You sent me the text <strong> " & order_number & " </strong> to process...
</body>
</html>"
on error
set Error_Code to "Error: missing field "search-string"." as string
--if there was no text, or some other problem occurred at least let the user know an error occurred.
return "<html>
<body>Sorry, I could not process your request because of the following error... <strong> " & Error_Code & "
</body>
</html>" as string
end try
end handle CGI request
*The CGI does not need to be running when the user hits it with a request but I notice it is more reliable
if it is.
Hope this helps you,
C.
Sometimes I post things in a hurry duing idle time and forget to verify things.
The CGI code I posted works but only if you have the Speak.cgi scripting addition
installed. Standard Addition also has a method of parsing the CGI arguments but
I just happened to post this. If you are stumped on where to find the Speak.cgi
scripting addition you can get it here:
http://files.macscripter.net/ScriptBuilders/WWW/Speak.cgi_1.2_Installer.hqx
Or you could just check out the Standard Additions Handle CGI command to get the data.
Sorry for any frustration I may have caused.
Best,