https Help Needed
Sarah Reichelt
sarah.reichelt at gmail.com
Wed Aug 29 20:05:31 EDT 2007
On 8/30/07, Mark Smith <mark at maseurope.net> wrote:
> Sorry, I take that back. I don't think it will work because shell
> calls are blocking - your app will do nothing until the shell call to
> curl is completed, appending an ampersand (to put the process in the
> background) doesn't work in Rev on OS X.
I don't know anything about HTTPS so can't help you there, but I do
have a technique for non-blocking shell calls which might help. I have
included my ping function below which uses the shell ping command with
extra parameters that tell it to send the result to a file. Then I
just have a loop that checks for that file and when it has arrived,
reads the result that way.
Pinging is instant when it works, but takes a long time to fail, so I
find this trick works really well. Maybe you could do something
similar.
function checkPing pIP
put specialFolderPath("Desktop") & "/ping.txt" into tFileName
if there is a file tFileName then delete file tFileName
put "ping -c1 -n " & pIP into tShellCmd
put " > " & tFileName & " 2>&1 &" after tShellCmd
get shell(tShellCmd)
put 0 into timeCheck
repeat 50 times
add 1 to timeCheck
wait 1 tick with messages
if there is a file tFileName then
put URL ("file:" & tFileName) into tRes
if tRes is empty then next repeat -- file created but no result yet
put wordOffset("loss", tRes) into tWord
if tWord = 0 then next repeat -- file created but result
not complete
-- if there is a file tFileName then delete file tFileName
put word tWord-2 of tRes into tPercent
if tPercent = "0%" then return true
else return false
end if
end repeat
if there is a file tFileName then delete file tFileName
return false
end checkPing
Cheers,
Sarah
More information about the use-livecode
mailing list