On Thu, Apr 22, 2010 at 1:05 PM, John W. Krahn <jwkr...@shaw.ca> 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);

for my $line (<$pipe>)
{
    # Parse columns from $line here.
    # For example, let's just print them.
    print $line;
}

close($pipe);

__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.


-- 
Brandon McCaig <bamcc...@gmail.com>
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software <http://www.castopulence.org/> <bamcc...@castopulence.org>

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to