Brandon McCaig wrote:
On Thu, Apr 22, 2010 at 1:05 PM, John W. Krahn <[email protected]> wrote:
What does that sentence mean?  What would the number returned from the shell
(bash, csh, ksh, etc.) have to do with the numbers output from "runmqsc
SQFR"?

Perhaps he really wants to read and parse the output from the
command(s) instead of checking the status?

my $cmdline = "echo 'DIS CHS(*)' | runmqsc SQFR | grep CHANNEL | sort
| uniq -c";

# Open input pipe from command line.
open(my $pipe, "-|", $cmdline);

open my $pipe, '-|', $cmdline or die "could not open pipe: $!\n";


for my $line (<$pipe>)

while( my $line = <$pipe> )

{
    # Parse columns from $line here.
    # For example, let's just print them.
    print $line;
}

close($pipe);

close $pipe or die "could not close pipe: $!\n";


__END__

This is similar to piping the command to your program and reading from STDIN.

# Shell command.
$ echo foo | your_program

You can learn about the various modes of the open function with
`perldoc -f open'. Look for the MODE argument in relation to command
pipes.




--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to