]> Pileus Git - ~andy/fetchmail/blob - contrib/preauth-harness
Add new gai.c debug source.
[~andy/fetchmail] / contrib / preauth-harness
1 #!/usr/bin/perl
2
3 BEGIN { $SIG{'__WARN__'} = sub {};};
4
5 $hostname = "criens.u-psud.fr";
6 $username = "p99dreyf";
7 $passwd = "xxxxxxxx";
8 $command = "exec ~/bin/imapd";
9
10 use Net::Telnet ();
11 $host = new Net::Telnet (Timeout => 10,
12                          Port => 23,
13                          Prompt => '/p99dreyf>\s?$/',
14                          Cmd_remove_mode => 1);
15
16 $host->option_accept(Dont => &Net::Telnet::TELOPT_ECHO,
17                      Wont => &Net::Telnet::TELOPT_ECHO);
18                      open (FILE,">log");
19 $host->dump_log("log2");
20 $host->input_log("log3");
21 ## Issue some commands.
22 $host->open($hostname);
23 #$host->login($username, $passwd);
24 $host->waitfor('/login:\s?$/');
25 $host->print("$username");
26 $host->waitfor('/Password:\s?$/');
27 $host->print("$passwd");
28 $host->waitfor('/p99dreyf>\s?$/');
29
30 $host->print("$command");
31 $strip=1;
32 while ($strip) {
33         $greeting=$host->getline();
34    if ($greeting=~/^\* PREAUTH.*$/) { print "$greeting"; $strip=0;};
35 }
36     do {
37       do {
38         $cmd=<STDIN>;
39         chop $cmd;
40       } while ($cmd !~/[A-Za-z0-9]/);
41       $host->print("$cmd");
42       print FILE ">>$cmd<<\n";
43       do {
44         $line=$host->getline();
45         chop($line);
46         print "$line\n";
47         print FILE "<<$line<<\n";
48       } while (($line!~/^[A-Za-z0-9]+ (OK|BAD|Expunge).*$/) &&
49                 ($line!~/^\* BAD.*$/));
50       print FILE "--next cmd\n";
51     } while ($line!~/^[A-Za-z0-9]+ OK LOGOUT.*$/);
52
53 exit;