• 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: ACGI form parsing in OSX?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ACGI form parsing in OSX?


  • Subject: Re: ACGI form parsing in OSX?
  • From: James Sentman <email@hidden>
  • Date: Fri, 1 Feb 2002 11:57:50 -0500

Jeff,

James, I'm glad you're on board for getting ACGIs working in X. The handler
for parsing that you provided is incomplete. We (OK, I) need a way to deal
with the fact that form POST data arrives URL encoded. My experience is that
pure Applescript approaches to this are sloooooow.

If you mean that it arrives in the form of "hello There" and such then yes thats true. I obviously forgot that the mac webservers took care of fixing this for you and I can do that to the data before it gets to your program. I'll try and do that this weekend.

If you mean that it comes in a big string like name=value&name=value&name=value... I think that is how it is supposed to work isn't it? Parsing this is not as difficult and you can find an example of it, either in my post from yesterday or actually working in the iTunes control script that is in the package with the program.

With all this talk of the Unix, is there a way to do this with the shell?
Anyone?

I have a partial answer in Perl, which I have running to handle incoming posts, but I don't know how to translate this into a do a shell script. So maybe someone will help us get multi-line perl scripts to run in the shell and return the processed results. This is a simplified version of what my perl script does:

#here we determine whether it's a post or get method
$method=$ENV{REQUEST_METHOD};
if ($method =~/get/i)
{
$input = $ENV{QUERY_STRING};
}
else
{
read (STDIN, $input, $ENV{CONTENT_LENGTH});
}

#now we have the full request in and split it up into name=value pairs
($comm, $value) = split(/=/, $input);

if ($comm eq "keyname")
{
#here is the key for URL decoding
$value =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge;
}

... quite a bit more stuff follows that writes stuff to files, but the essential part for URL decoding is listed above.

So if anyone can tell us how to run this regular expression substitution in the shell, we should have a nice URL decoder.

unfortunately, the only option for sending an apple event from a perl script or a shell script (at least the only one I know of) is to pipe the events in the form of a script to the osascript command line program. This works great from a normal terminal, but doesn't work at all when run from the web server as a cgi script.

If you want to rewrite your program in perl or php then that code will work just fine, (you can even contract me to do it if you want;) but you cannot launch osascript or any other carbon/cocoa app when running as the web server. I'm not sure why this is and spent a long time trying to find a workaround for this. Even creating SUID scripts and such to force the script to run as someone else. There is something missing in the environment that the web server runs in that just wont let these other apps startup. They crash when trying to init core graphics. Why a command line app like osascript wants to init core graphics I dont know, perhaps thats the bug.

Beyond that the latency of starting up osascript is much longer than the current program that I'm using. There seems to be a large overhead to running a script with it. Running tests outside of the webserver I've found it to be about twice as slow, or slower, than using acgi dispatcher.

Anyhow, I'll fix the urlencode problem this weekend.

Anyone else following the discussion wants to pick up the program it's at:
http://www.sentman.com/acgi

Thanks,
James
--
_________________________________________________________________________
James Sentman <email@hidden> http://www.sentman.com
Enterprise server monitoring with: http://whistleblower.sentman.com/


  • Follow-Ups:
    • Re: ACGI form parsing in OSX?
      • From: Reinhold Penner <email@hidden>
  • Prev by Date: Re: Question: How do you open scripts?
  • Next by Date: Pause script until application is finished
  • Previous by thread: Re: Question: How do you open scripts?
  • Next by thread: Re: ACGI form parsing in OSX?
  • Index(es):
    • Date
    • Thread