Hi, I'm on a public Wifi connexion that disconnects every 30' and
shows a web page where you need to wait 30" before submitting a form
to get the connection back. Their connexion method is twofold : first
there is a post form that gets you to a web page where a new form is
generated, including a randomly generated login/pw, then this form
gets sent through get.
I'm using this script to send the first form :
===
set remoteApp to "https://secure2.stuff.com/2mlns/login"
set URLEncodedVars to "return_to=https://access.stuff.net:8090/goform/
HtmlLoginRequest"
do shell script "curl -kd " & URLEncodedVars & space & remoteApp
===
....which works ok, and returns this:
===
" <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>stuff Wireless - Login</title>
<meta http-equiv=\"Cache-control\" content=\"no-cache\">
<meta http-equiv=\"Pragma\" content=\"no-cache\">
<link rel='stylesheet' type='text/css' href='style.css'
title='stuff' />
<script type=\"text/javascript\">
function submit_form()
{
do***ent.log_in.submit();
}
</script>
</head>
<body onload='submit_form();' oncontextmenu=\"return false\"
ondragstart=\"return false\" onselectstart=\"return false\">
<h1 style=\"text-align: center;\">Connecting...</h1>
<form name=\"log_in\" action=\"https://access.stuff.net:
8090/goform/HtmlLoginRequest\" method=\"get\" id=\"log_in\">
<input type=\"hidden\" name=\"username\" value=
\"rytcptqeanh\" />
<input type=\"hidden\" name=\"password\" value=
\"scxplcaoatx\" />
</form>
</body>
</html>"
===
Now I need to parse this result, get the randomly generated login and
password fields and use them in a curl get form like this one:
===
curl -k "https://access.stuff.net:8090/goform/HtmlLoginRequest?
&id=log_in&username=rytcptqeanh&password=scxplcaoatx"
===
Then I'd be using all this within a script that sends a ping every 5
seconds, and would launch the curl stuff above on ping error (instead
of the static html file I'm using below), so that instead of poping up
an html file within a new window in Firefox everytime the connexion is
lost, all this would be done in the background.
===
repeat
try
set ping_result to (do shell script "ping -c 1 www.google.com")
set AppleScript's text item delimiters to " packet loss"
set ping_result to text item 1 of ping_result
set AppleScript's text item delimiters to "packets received, "
set ping_result to text item 2 of ping_result
if ping_result is "100%" then
tell application "Firefox"
open "/path/to/your/file.html" as POSIX file
end tell
end if
on error
tell application "Firefox"
open "/path/to/your/file.html" as POSIX file
end tell
end try
delay 5
end repeat
===
As an option, I would be happy to make the repeat delay 5" if the ping
is ok (as it is above), but only 2" if the ping fails.
Many TIA's!


|