--- misc/mailinfo/mailinfo.pl 2001/07/19 11:11:33 1.1 +++ misc/mailinfo/mailinfo.pl 2001/10/15 16:29:03 1.6 @@ -9,7 +9,7 @@ # - T.D.Bishop@ukc.ac.uk # # $Author: tdb $ -# $Id: mailinfo.pl,v 1.1 2001/07/19 11:11:33 tdb Exp $ +# $Id: mailinfo.pl,v 1.6 2001/10/15 16:29:03 tdb Exp $ #------------------------------------------------------------ $| = 1; @@ -23,7 +23,7 @@ my($mailinfo_port) = "912"; # default settings my($mailinfo_mode) = "mi_guess"; -my($mailinfo_name) = getlogin; +my($mailinfo_name) = ""; my($mailinfo_quick) = 0; # work out the switches @@ -57,10 +57,12 @@ while(@ARGV) { &usage; } else { - $mailinfo_name = $opt; + $mailinfo_name .= " $opt"; } } +if($mailinfo_name eq "") { $mailinfo_name = getlogin; } + # run mailinfo &mailinfo($mailinfo_server, $mailinfo_port, $mailinfo_mode, $mailinfo_name, $mailinfo_quick); @@ -85,34 +87,37 @@ sub mailinfo() { PeerAddr => $server, PeerPort => $port, Proto => 'tcp' - ) or die "Cannot connect!"; + ) or die "Connection to server broken\n"; if(!defined $sock) { - print "unable to connect to mailinfo server: $server:$port"; + print "Connection to server broken\n"; exit(1); } - my($response); + my($response) = ""; # set the sensible option if we want quick mode if($quick) { - print "DEBUG sensible on\n"; print $sock "sensible on\n"; $response = <$sock>; while($response ne ".\n") { - #print "$response"; $response = <$sock>; } } # send the query print $sock "$mode $name\n"; + $response = ""; - # read and print the response - $response = <$sock>; + # read and print the response while($response ne ".\n") { - print "$response"; $response = <$sock>; + if($response =~ s/^\?/mailinfo: /) { + print $response; + } + else { + print $response unless $response eq ".\n"; + } } # quit and close