expect-like package
Eric McCoy
ctr2sprt at comcast.net
Tue Dec 20 16:38:46 EST 2005
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.
More information about the Python-list
mailing list