[Wylug-help] Fw: Automate Web logins

James Holden wylug at jamesholden.net
Wed Jun 30 14:56:07 BST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Smylers wrote:
| Idris Fulat writes:
|
|
|>PS.. just out of interest my VB code opens IE 'looks' for the login
|>and password fields, fills them in and then submits and then closes IE
|>(its like a background task without actually showing the IE window so
|>the user continues with their IE session).

Well, that's one way of doing it. :-)

| Oh, wow.  (And I don't mean that in the good way ...)

It's not particularly great, but Symantec have deliberately made the
process different. I sense a culture clash coming.

|>The linux alternatives seem awfully complicated from my point of view.

Well, that's because it's more complicated than it seems.

It isn't just a case of:

wget http://loginserver/loginscript?user=foo&password=bar

For starters, you'd never use the GET method for a login form.

In this particular case there's also a hidden field containing a random
number to submit, and a cookie to handle. This is why the other Linux
solutions are more complicated.

| Which just shows that people have different viewpoints!  On reading your
| description of how it works in Windows I couldn't believe how
| complicated _that_ was.

Yes, but the script itself is quite simple and works.

| My way of thinking about it is that so far as the web-server is
| concerned, the process of logging in involves receiving a single HTTP
| request.  Therefore what we want is a script that sends a single HTTP
| request, and anything else is overkill.

Yes, and that's what happens. IE is overkill, but wget can do a awful
lot more than just send a single HTTP request. Another alternative is to
use lynx with the -d (dump) option. You're still starting an entire
browser to make a single HTTP request.

Really, to solve the problem here, you need to make two calls to lynx
(wget can't to POST requests). The first call gets the hidden ID and
cookie, and the second send the actual request. Idris's script only
fires up IE once, and it takes care of the hidden field and cookie
automatically.

Given all that, on Unix, perl and WWW::Mechanize is probably the best
tool for the job here. Also, if anything goes wrong you'll get the
output from the cron job mailed to you.

|>Is it not possible for 'something' to call mozilla 'look' for the
|>fields and fill and submit.
|
|
| It quite possibly would be, but that involves doing so much more than
| simply sending an HTTP request that it becomes much more fraught; there
| are more places where it can go wrong.

Yes, I believe it can be done.

| It would require a graphical display for the user it's running as, which
| requires them to be logged in somewhere.  If that user logs out (perhaps
| they want to change their X settings, or they've just bought a new mouse
| or something) then the task won't run.

Not necessarily. If you really need to fire up an X11 app to do some
scripted task, it would be more sensible to use an separate X server
will null display device.

| But automated tasks don't usually involve graphical interfaces; guis
| were created to make it easier for humans to interact with computers,
| and it doesn't really make sense to force an automated task have to use
| a gui.  The task doesn't need any kind of graphical output or display,
| so including them is superfluous and adding to the list of things that
| can go wrong.

Correct, but if you 'Dim IE as InternetExplorer' no interface is drawn
on the screen. It *could* be, but in this case it isn't.

| So automated tasks on Unix-like systems tend to be specified in terms of
| non-graphical commands.  That's one of the best features of Unix, that
| the canonical form of most commands is command-line based, and the
| various graphical interfaces are just front-ends which call command-line
| equivalents underneath; so for very many tasks which you can point-and-
| click, you can also script them straightforwardly.

I completely agree. But, it's not the case in the world of Windows.
Windows is generally poor for scripting and automation, but Idris's
script does the job within the confines of what's available to you.

|
|>but I really thought it would have been a much simpler process. I've
|>attached the VB code if you're interested.
|
|
| Having looked at your VB code, the Perl code using WWW::Mechanize would
| be very similar -- everything would be spelt differently and there'd be
| more punctuation marks of course, but the complexity and number of
| tokens would be about the same.

Indeed.

| The only difference is that in VB you're driving a gui app with a
| script, and in Perl you're using a library that was specifically
| designed for being scripted.  (And if you use HTTP::Recorder then you
| don't even have to do the scripting yourself.)

True, but in a sense, IE is being used like a library. Functions from IE
are available in the VB namespace so it's not really much different.
It's behaving like a library, but it just has the possibility of going
GUI if needed.

Hmmmmm....  have I just defended Windows on a LUG list? ;-) It was an
accident, honest!


James



| Smylers
|
|
| _______________________________________________
| Wylug-help mailing list
| Wylug-help at wylug.org.uk
| http://list.wylug.org.uk/mailman/listinfo/wylug-help


- --
James Andrew Holden, Leeds, UK    (james at jamesholden dot net)
GPG Key: 1024D/8358863A    *Please encrypt mail where possible!*
Fingerprint:  32C9 A76F 3CFE A06C 1B00  5AAB 9877 4742 8358 863A
jamesholden.net ICQ: 11290827 >Buy Linux CDs from fastdiscs.com<
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFA4sZ3mHdHQoNYhjoRAtO7AJ46zIiUMr1VY01TqTOKAO7KlCvxDQCcCwc7
yaVA62edAcO0pKpT3R1ibAI=
=AT2z
-----END PGP SIGNATURE-----




More information about the Wylug-help mailing list