expect-like package

Discussion in 'Python' started by Eric McCoy, Dec 20, 2005.

  1. Eric McCoy

    Eric McCoy Guest

    I'm looking for a way to create simple scripts which should be
    accessible to a technical, though non-programmer, person. These scripts
    are basically network service checks so I don't need much power: "send
    this line," "if this line matches, keep going," and "if this line
    matches, quit immediately." So for HTTP, for example, I'd use something
    like this:

    send "HEAD / HTTP/1.0"
    send "Host: server.host.name"
    send ""
    expect ...
    "^HTTP/1\.0 200.*" then return success
    "^HTTP/1\.0 4\d\d.*" then return warning
    else return error

    It would also be nice if a more complex version could be written to
    handle redirects by grepping out the new target and then attempting to
    fetch that URI, but that's not a requirement.

    I looked at expect and a pure-Python reimplementation of same, but they
    both want to spawn external processes. Since I will be running more
    than 10 checks a second that would be bad. I also need to be able to
    implement a hard timeout, so if any check takes longer than, for
    example, 5 seconds, it automatically fails. A log of the transaction
    would also be good so that we can quickly find out why checks are
    failing. And another reason not to do this in Python is that I want
    checks to be configurable on the fly and stored in a database. I know
    Python can do that but I want them sandboxed so that an error in a
    user-built script won't take down the entire application.

    I can roll my own but that would be a PITA so I'd prefer to use an
    existing package if one exists. Anyone know of any? Thanks!

    P.S. I will try to monitor the group but email replies would be appreciated.
    Eric McCoy, Dec 20, 2005
    #1
    1. Advertising

  2. Stephen Thorne, Dec 21, 2005
    #2
    1. Advertising

  3. In article <>,
    Stephen Thorne <> wrote:
    >On 21/12/05, Eric McCoy <> wrote:
    >> So for HTTP, for example, I'd use something
    >> like this:
    >>
    >> send "HEAD / HTTP/1.0"
    >> send "Host: server.host.name"
    >> send ""
    >> expect ...
    >> "^HTTP/1\.0 200.*" then return success
    >> "^HTTP/1\.0 4\d\d.*" then return warning
    >> else return error

    >
    >Have a look at these:
    > http://www.idyll.org/~t/www-tools/twill.html
    > http://pbp.berlios.de/
    > http://www.openqa.org/selenium/

    .
    .
    .
    In a different direction, <URL: http://pexpect.sf.net >.
    Cameron Laird, Dec 21, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Rutt
    Replies:
    0
    Views:
    309
    Benjamin Rutt
    Mar 30, 2006
  2. Klein Stéphane
    Replies:
    3
    Views:
    583
    Steve Holden
    Dec 20, 2009
  3. Asfand Yar Qazi

    OptionParser doesn't work like I expect?!

    Asfand Yar Qazi, Mar 10, 2005, in forum: Ruby
    Replies:
    0
    Views:
    95
    Asfand Yar Qazi
    Mar 10, 2005
  4. Simon Strandgaard

    how to expect eof with expect+pty

    Simon Strandgaard, Dec 20, 2006, in forum: Ruby
    Replies:
    4
    Views:
    337
    Simon Strandgaard
    Dec 20, 2006
  5. Phil
    Replies:
    0
    Views:
    157
Loading...

Share This Page