File: test-booldnf.pl

package info (click to toggle)
boolstuff 0.1.14-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,796 kB
  • ctags: 299
  • sloc: sh: 11,017; cpp: 1,649; makefile: 220; ansic: 165; perl: 106
file content (34 lines) | stat: -rwxr-xr-x 656 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl -w
#
# $Id: test-booldnf.pl,v 1.3 2005/02/03 23:26:43 sarrazip Exp $
#
# Example of bidirectional pipes to talk to the booldnf(1) command
# from a Perl script.
#
# Written by Pierre Sarrazin <http://sarrazip.com/>
# This file is in the public domain.
#

use strict;
use IPC::Open2;


my $command = shift || "booldnf";
my ($reader, $writer);
my $pid = open2($reader, $writer, $command);
if (!defined $pid)
{
    print "open2: $command: $!\n";
    exit 1;
}

while (<>)
{
    print $writer $_;
    my $response = <$reader>;
    print "Response: $response";
}

close $reader;
close $writer;
waitpid $pid, 0;  # see the IPC::Open2 manual page.