• 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: URL Access Scripting Not Launching
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: URL Access Scripting Not Launching


  • Subject: Re: URL Access Scripting Not Launching
  • From: "Daniel A. Shockley" <email@hidden>
  • Date: Mon, 4 Nov 2002 16:30:26 -0500

Ken (and anyone interested in using curl),

Here's a simple handler that does GET and POST downloads, with the option to return the source directly, rather than saving to file. The example calling the handler is first. Here's hoping the line returns don't break it up too much:


set actionURL to "http://www.idocs.com/cgi-bin/mycgi.pl";
set testFormInfo to "realname=Dan Shockley&email=email@hidden&" & ,
"nosmoke=on&myself=Here's my little bio about myself."
-- to submit no form data, just make this ""

set saveFilePath to (path to desktop as string) & "TEMP:PostResultFile.html"

curlSimpleDownload(actionURL, saveFilePath, testFormInfo)



on curlSimpleDownload(downloadURL, destExpected, theFormInfo)
-- version 1.0, Daniel A. Shockley - public domain
-- downloadURL is STRING
-- saves to destExpected
-- (Mac path as STRING, FILE SPEC, or ALIAS), if given
-- if file path is "", returns source
-- optional form data for POST - use "" for no form data

-- basic download to standard output
set curlCode to "curl \"" & downloadURL & "\""

-- now, add on the desired file location, if there is one given
if destExpected is not "" then
set unixDestExpected to POSIX path of (destExpected as string)
set curlCode to curlCode & " --output \"" & ,
unixDestExpected & "\" --write-out \"%{http_code}\""
end if

if (length of theFormInfo) > 0 then
set curlCode to curlCode & " -d \"" & theFormInfo & "\""
end if

set curlResponse to do shell script curlCode

return curlResponse
(*
curlResponse will be the http success code ("200"), or an error code.
If no destination was given, curlResponse will be the source
returned, and no file will be saved
*)
end curlSimpleDownload


I'll check out Curl on Monday, but a question first. If I find it to be helpful, can I script it? This needs to be part of a CGI that I'm writing and I only know AppleScript (please don't suggest PHP, etc. I don't have time to learn another language for this project). In the worst case, I can use the classic version of UAS because I already have it working. It's pretty fast once it's launched, but there's a noticeable delay when classic has taken a nap and UAS must re-launch. At least it works!

Ken Fleisher


--
----
Daniel A. Shockley
email@hidden
email@hidden
http://www.danshockley.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: AppleScript's script size limit
  • Next by Date: iCal scripting samples
  • Previous by thread: Re: URL Access Scripting Not Launching
  • Next by thread: Re: URL Access Scripting Not Launching
  • Index(es):
    • Date
    • Thread