Operating System - HP-UX
1753505 Members
4760 Online
108794 Solutions
New Discussion юеВ

can PERL handle multiple pipes on 1 line?

 
SOLVED
Go to solution
Rick Garland
Honored Contributor

can PERL handle multiple pipes on 1 line?

Hi all:

Using perl 5.8.3 on a HPUX 11.00.

I have a perl script for helpdesk to assista in management of printers.

A new option, search all printers for a pattern
Easy enough, use grep.

elsif ($choice eq '8') {
print "Search a specific print queue - what is partial printer name? ";
$prt = ;
system "/usr/bin/lpstat -t \| grep -i $prt";
&TheMenu;
}

But if I want to add another pipe to 'more', it gives me a syntax error.

system "/usr/bin/lpstat -t \| grep -i $prt | more";


There could be hundreds of printers matching the pattern so I need to page the output. But how do I pipe to more with the above command?
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: can PERL handle multiple pipes on 1 line?

Yes, in this case the system call is simply passed to the shell. The confusion is caused by a LF in stdin.

I'll bet this works:
$prt = "xxx";
system("lpstat -t | grep -i $prt | more")

however your example fails.

after your:
$prt = ;
add this line:
chomp($prt);
I think that will fix you.

I also notice that you escaped one of your pipe symbols but not the other; you shouldn't need an escape.
If it ain't broke, I can fix that.
Rick Garland
Honored Contributor

Re: can PERL handle multiple pipes on 1 line?

Hi Clay:

Both ways work. Many thanks.