• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: PHP and Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: PHP and Applescript
      • From: has <email@hidden>
References: 
 >a date is not a date? Or: Why I sometimes hate AppleScript... (From: Skeeve <email@hidden>)
 >PHP and Applescript (From: Grace Finn <email@hidden>)
 >Re: PHP and Applescript (From: Brian Johnson <email@hidden>)

  • Prev by Date: Re: A date IS a date
  • Next by Date: Re: A date IS a date
  • Previous by thread: Re: PHP and Applescript
  • Next by thread: Re: PHP and Applescript
  • Index(es):
    • Date
    • Thread