Afficher un message
Vieux 05/05/2008, 21h59   #11
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Usenet server test script

2008-05-5, 00:37(+02), Theo v. Werkhoven:
[...]
> #v+
> !/usr/bin/expect --


ITYM

#! /usr/bin/expect --

> spawn telnet [lindex $argv 0 ] 119
> expect -re "200(.*)$"


That's a common mistake with expect. "200(.*)$" will match
anything from the first "200" until the end of the current
buffer (what's been read so far from the spawned command), not
to an end-of-line.

Also, you don't do anything in case of timeout, so you might as
well expect any return code.

If you really want to check the return code, you may want to
check that 200 appears at the start of the buffer as well, in
cases of "502 more than 1200 users logged in".

You may want to accept a code of "201" as you don't intend to
post.

If you want to do things properly, you'll soon realise that you
are actually rewriting a NNTP client, so best would be to use an
existing one or some NNTP module in some scripting language.

> send "body [lindex $argv 1]\r"
> expect -timeout 1 -re "^\.$"


Same problem as above. The end pattern to look for is
"\r\n.\r\n", Here, you're expecting the first read from the
command to return only "." which is very unlikely.

--
Stéphane
  Réponse avec citation
 
Page generated in 0,05140 seconds with 9 queries