LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Automating lynx prompt enties (https://www.linuxquestions.org/questions/linux-software-2/automating-lynx-prompt-enties-137448/)

cmfarley19 01-22-2004 09:53 AM

Automating lynx prompt enties - Firewall Authentication
 
A couple of us on campus use shh tuneling to access our private e-mail accounts on our home machine. Recently, "The Man" installed some firewall software that requires us to authenticate a connection to the 'net. If using Windows or Linux GUI, a standard dialog box pops up, you enter your username and password info click 'OK' and you're good to go.

From command line Linux, if you run something that needs access to the net, no prompt is displayed and the system hangs until a connection time out.

We found a way around this by running lynx and requesting a common sit like www.somesite.com.
Code:

$ lynx www.yahoo.com
lynx launches, requests the site, the firewall says "Hey, you're not authorized" then askes for a username.
Code:

Username for 'FW-1.      Reason: no user      FW-1 ' at server 'XXX.XXX.XXX.XXX':
You enter your user name then...
Code:

Password:
You enter your password and your in.

You now have an authenticated connection to the net to use as you please.

The session expires after X minutes or X minutes of inactivity. (Haven't figured that one out yet.

What we want to do is run a cron job that will automate the above process.
1) Launch lynx and request a site
2) Enter username and password when and if prompted

We're stuck on how to automate the entry of the username and password.

Anyone have any ideas?

cmfarley19 01-22-2004 10:32 AM

After seaching some related posts, I decided to read the lynx man page.
Code:

$lynx -auth=username:password www.somesite.com
will do the trick.

stickman 01-22-2004 12:21 PM

Or you might consider putting it in a conf file so that anyone who does a ps won't see your password.

cmfarley19 01-22-2004 12:31 PM

Stickman...
Unfamiliar with the conf file.
Do tell...

stickman 01-22-2004 09:52 PM

From the man page for lynx:
-cfg=FILENAME specifies a Lynx configuration file other than the default lynx.cfg.

Find the lynx.cfg (probably somewhere in /etc), and use it as a basis for a personal config file.

cmfarley19 01-23-2004 08:09 AM

Stickman... thanks. Will try.

All...
New question...
I worte two small shell scripts
tunnel_start.sh
Code:

#!/bin/bash

lynx -auth=uname:password www.yahoo.com

and tunnel_stop.sh
Code:

#!/bin/bash

kill `ps aux | grep  lynx |  grep -v grep | awk '{print $2}'`

I've mad the following crontab entries:
Code:

0 7-16 * * 1-5 /home/cfarley/lynx/tunnel_start.sh #> /dev/null 2> /dev/null
1 7-16 * * 1-5 /home/cfarley/lynx/tunnel_stop.sh #> /dev/null 2> /dev/null

The first script executes and dies immediately. Here is the output:
Code:

  Your Terminal type is unknown!

  Enter a terminal type: [vt100]
TERMINAL TYPE IS SET TO vt100
(B)0[?7h[?1h=Looking up www.yahoo.com first
Getting http://www.yahoo.com/ 
Looking up www.yahoo.com    
www.yahoo.com          
Making HTTP connection to www.yahoo.com
Sending HTTP request.                  
HTTP request sent; waiting for response.


[?1l>

I would expect that the first script would launch lynx, run for 1 minute, then the second script would kill lynx.

I would also expect lynx to have authenticated the firewall prompt as it does if you execute the command from the command line.

It did not.

Any thoughts?

stickman 01-23-2004 03:23 PM

You could use -dump or -source so that Lynx exits after it grabs the page the you don't need the second script to kill Lynx.


All times are GMT -5. The time now is 05:40 AM.