X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fwinclient.pl;h=58db0b8c95f4ce960f4adbddabac9cd618738335;hb=076b94b8ba5b24af929056d5e4c5217427f93b9e;hp=e0c89efe4174a3e21b5a228794fd97a96b108554;hpb=6daf175d1dba2651fb5af4a611e2e04ddc19c11a;p=spider.git diff --git a/perl/winclient.pl b/perl/winclient.pl index e0c89efe..58db0b8c 100755 --- a/perl/winclient.pl +++ b/perl/winclient.pl @@ -70,20 +70,27 @@ die "can't fork: $!" unless defined($childpid = fork()); # the communication ..... if ($childpid) { + my ($lastend, $end) = ("\n", "\n"); + STDOUT->autoflush(1); while (defined (my $msg = <$handle>)) { my ($sort, $call, $line) = $msg =~ /^(\w)([^\|]+)\|(.*)$/; + next unless defined $sort; + $line =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg; if ($sort eq 'Z') { kill 'TERM', $childpid; + exit(0); } elsif ($sort eq 'E' || $sort eq 'B') { ; } else { # newline ends all lines except a prompt - my $end = "\n"; - if ($line =~ /^$call de $mycall\s+\d+-\w\w\w-\d+\s+\d+Z >$/) { + $lastend = $end; + $end = "\n"; + if ($line =~ /^$call de $mycall\s+\d+-\w\w\w-\d+\s+\d+Z >$/o) { $end = ' '; } - print $line . $end; + my $begin = ($lastend eq "\n") ? '' : "\n"; + print $begin . $line . $end; } } kill 'TERM', $childpid;