LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Simple webserver test script (bash) (https://www.linuxquestions.org/questions/programming-9/simple-webserver-test-script-bash-134607/)

somedudeppf 01-14-2004 12:21 AM

Simple webserver test script (bash)
 
ok, I'm trying to do something simple and overcomplicating myself again...

I want to test an old pc of mine as a webserver. I'd like to:

open 5 concurrent connections to www.whatever.com

wait 5 seconds

close connections

loop


I've tried a few runs at it using w3m as my command line browser (which is probably the wrong thing to do) and had no success with the closing of the browser using $TIMEOUT or kill $!

any help would be greatly appreciated!

thanks in advance,

adam

fluppi 01-14-2004 02:03 AM

Well, 5 seconds are maybe a little to fast to establish all those connections, and your server could be limited to 4 sessions from the same computer.

This line works for me with the lynx Textbrowser:
lynx -accept_all_cookies -dump http://www.whatever.com > dumpfile.txt
Now you can parse the file for "Error", "404" etc.

There a a few more parameters for lynx, like source, auth.

Very intresting could it be, to measure the time it takes to get the page.

Hth
Fluppi

ilikejam 01-14-2004 02:26 AM

Hi. I don't know if it's what you're looking for, but the following will kill all instances of a program - you could launch 5 instances of (for example # lynx www.whatever.com), wait 5 seconds, and kill them all with:

# ps -A | grep lynx | awk '{print $1}' | xargs kill -9

5 seconds later.

e.g.
#!/bin/bash
while true; do
lynx www.whatever.com &
lynx www.whatever.com &
lynx www.whatever.com &
lynx www.whatever.com &
lynx www.whatever.com &
sleep 5
ps -A | grep lynx | awk '{print $1}' | xargs kill -9
done

It'll mess up your console while it's running, but it works.

Or you could use 'wget' to request whatever resources you want - wget returns to the console after it's finished downloading, so you wouldn't have to kill the processes.

Dave

somedudeppf 01-14-2004 10:30 AM

hmm, interesting indeed. it looks like some of the things i've tried with slight variations..

thanks very mutch!


adam


All times are GMT -5. The time now is 04:45 AM.