[PLUG] command line http authentication
Pradeep Dalvi
technical at dalvi.co.in
Sun Mar 8 00:32:37 IST 2009
You are probably looking for the script below.
1. Open the login page in browser
2. View the page source
3. Find out form tag
4. Check for input fields
5. Get the form action url
6. Fill in all <> fields below
7. Add the script into crontab with some interval
P.S. Sometimes the input fields are combined/manipulated using
Javascript and then submitted to login URL. So find out final fields
to be submitted & the final URL.
Please remember that you are trying simulate what browser does!
--
prad
# crontab -l
*/10 * * * * /usr/local/bin/connectme
$ cat /usr/local/bin/connectme
#!/bin/bash
USERID=<USERNAME>
PASSWORD=<PASSWORD>
curl -L www.google.com &> /tmp/data;
cat /tmp/data | grep <Some identical word from ISP Login page> &> /dev/null;
EXITSTATUS=$?;
if [ $EXITSTATUS == 0 ]
then
echo "Connecting to My ISP";
curl -d "username=$USERID&password=$PASSWORD" http://<ISP
Action URL> --retry 5
fi
On Sat, Mar 7, 2009 at 8:15 PM, Mayuresh <mayuresh at acm.org> wrote:
> My ISP uses http authentication. So user has to go to a certain https URL and
> login with username password etc.
>
> This forces me to use a browser to start my internet connection.
>
> Is there any way to do above https interaction using (say) a command line
> tool - basically non interactively rather than command line vs gui?
>
> One reason to look for this is to generally avoid having to launch the browser
> just for authentication when you might not actually need it otherwise.
>
> Another, more compelling reason is, if you leave a large download unattended
> for hours and if the connection gets broken (let's bash ISP on some other
> thread for that ;-) it does not get reconnected automatically. There is no
> mechanism to keep retrying till the connection is re-established. (This used
> to happen so when I had a pppoe based connection.)
>
> Mayuresh.
>
> _______________________________________
> Pune GNU/Linux Users Group Mailing List
>
More information about the Plug-mail
mailing list