summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-16 20:46:32 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-16 20:46:32 +0000
commit399a24e1fd8c99ceb097f6948af08205008bad2a (patch)
tree66443b47e5d79634c771edc6b340debe1fe03a42
parent4d4dec33b67eb92793bd73b2f193cd99ed021319 (diff)
DEBUG=1 ./line_mediator.pl
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@294 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-xvest/line_mediator.pl9
1 files changed, 7 insertions, 2 deletions
diff --git a/vest/line_mediator.pl b/vest/line_mediator.pl
index acb9a036..4e899c39 100755
--- a/vest/line_mediator.pl
+++ b/vest/line_mediator.pl
@@ -10,7 +10,8 @@ use IPC::Open2;
use POSIX qw(pipe dup2 STDIN_FILENO STDOUT_FILENO);
#use IO::Handle;
$,=' ';
-my $quiet=$ENV{QUIET};
+my $quiet=!$ENV{DEBUG};
+$quiet=1 if $ENV{QUIET};
sub info {
print STDERR @_ unless $quiet;
}
@@ -24,7 +25,7 @@ if (scalar @ARGV) {
pop @c1;
my @c2=@ARGV;
@ARGV=();
-(scalar @c1 && scalar @c2) || die "usage: $0 cmd1 args -- cmd2 args; hooks up two processes, 2nd of which has one line of output per line of input, expected by the first, which starts off the communication. crosses stdin/stderr of cmd1 and cmd2 line by line (both must flush on newline and output. cmd1 initiates the conversation (sends the first line). QUIET=1 env var suppresses debugging output. default: attempts to cross stdin/stdout of c1 and c2 directly (via two unidirectional posix pipes created before fork). env SERIAL=1: (no parallelism possible) but lines exchanged are logged unless QUIET. if SNAKE then stdin -> c1 -> c2 -> c1 -> stdout";
+(scalar @c1 && scalar @c2) || die "usage: $0 cmd1 args -- cmd2 args; hooks up two processes, 2nd of which has one line of output per line of input, expected by the first, which starts off the communication. crosses stdin/stderr of cmd1 and cmd2 line by line (both must flush on newline and output. cmd1 initiates the conversation (sends the first line). DEBUG=1 env var enables debugging output. default: attempts to cross stdin/stdout of c1 and c2 directly (via two unidirectional posix pipes created before fork). env SERIAL=1: (no parallelism possible) but lines exchanged are logged if DEBUG. if SNAKE then stdin -> c1 -> c2 -> c1 -> stdout";
info("1 cmd:",@c1,"\n");
info("2 cmd:",@c2,"\n");
@@ -43,12 +44,16 @@ if ($serial || $snake) {
my $c2p=open2($R2,$W2,@c2);
if ($snake) {
while(<STDIN>) {
+ info("IN:",$_);
lineto($W1,$_);
last unless defined ($_=<$R1>);
+ info("IN|1:",$_);
lineto($W2,$_);
last unless defined ($_=<$R2>);
+ info("IN|1|2:",$_);
lineto($W1,$_);
last unless defined ($_=<$R1>);
+ info("IN|1|2|1:",$_);
lineto(*STDOUT,$_);
}
} else {