Re: PHP and Applescript
Re: PHP and Applescript
- Subject: Re: PHP and Applescript
- From: Brian Johnson <email@hidden>
- Date: Sat, 9 Feb 2008 13:07:36 -0800 (PST)
On Sat, 9 Feb 2008, Brian Johnson wrote:
I'll try to get back to this later today, but want to get this off (as
refutation bait) in the mean time.
And, indeed, after rediscovering why wheels work better with axles (no pun
intended), I did concoct a dataflow from PHP exec -> shell -> peacePipe ->
applescript and back. Way too convoluted and mysterious, but works.
1. "hello.acgi" Saved at the server root as stay-open application without
startup screen (be careful, ScriptEditor will try to hide a ".app" on the
end):
property crlf : (ASCII character 13) & (ASCII character 10)
property iloops : 0
on run
set iloops to 0
return
end run
on handle CGI request path_args
searching for search_args with posted data post_args using access method method from address client_address
from user username using password pw with user info from_user from server server_name via port server_port
executing by script_name referred by referer from browser user_agent using action act of action type atype
from client IP address client_IP of content type content_type with full request fullreq with connection ID connID
from virtual host vdir
set iloops to 0
return "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf &
"MIME-Version: 1.0" & crlf & "Content-type: text/html" &
crlf & crlf & "Whooopa!"
end handle CGI request
on idle
if (iloops > 3) then
tell me to quit
return
end if
set iloops to iloops + 1
return 2
end idle
2. "script.php" (also at the root)
<?php
header("Content-type: text/html");
echo exec("./hello.sh",$r,$s);
?>
3. "hello.sh" (at the root) (this is specific to the peacePipe
application; tabs separate http env fragments, only some of which are
used for this as there is no form data going in, etc.))
#!/bin/sh
echo "A B C D E E F hello.sc
/Library/Webserver/Documents/hello.acgi /hello.acgi H I J
K L M N O P Q R" |
/Library/WebServer/CGI-Executables/ppclient -a 127.0.0.1 -p 5555 ;
----------------
As Axel noted, there are almost certainly cleaner/better/quicker pure-php
ways to do most tasks (got details?), and it's all irrelevant if what you
want is the AppleScript source (if you mean "open" as "open in script
editor").
Good luck.
-b.johnson, dept of architecture, university of washington, seattle
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden