"Fossies" - the Fresh Open Source Software Archive

Member "sawdog-2.4/services/http" (30 Oct 2000, 769 Bytes) of package /linux/privat/old/sawdog-2.4.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/expect -f
    2 
    3 # HTTP Expect module for sawdog
    4 # this script requests a HEADer from the server given in the first command
    5 # line argument. If the response contains the string 'HTTP', for example in
    6 # 'HTTP/1.1 200 OK', the script terminates sucessfully.
    7 # If, after 10 seconds, there is no 'HTTP' response, we assume a failure and
    8 # exit with error code 1 
    9 # You can also use something like 'wget --spider' instead of telnet. 
   10 
   11 set env(TERM) vt100
   12 
   13 set timeout 8
   14 match_max 100000
   15 
   16 for {set x 0} {$x<3} {incr x} {
   17    spawn telnet $argv 80
   18    expect "Connection refused" {
   19       exit 2
   20    } "Escape character is '^\]'.\r\r" {
   21       send -- "HEAD / HTTP/1.1\r"
   22       send -- "Host: $argv\r\r"
   23       expect "HTTP" {
   24          exit 0
   25       }
   26    } 
   27    sleep 5
   28 }
   29 exit 1