Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An issue about handling square bracket

Status
Not open for further replies.

whn

Programmer
Oct 14, 2007
265
US
I wrote a autoinstallation tool in perl on linux.

While I install this package maunally, I see this message:

Code:
% rpm -ivh mypackage.rpm
Preparing...                ########################################### [COLOR=red][b][100%][/b][/color]
......
......

So in my code, I did this:

Code:
my $ret = `rpm -ivh mypackage.rpm`;
my @tmp = split(/\n/, $ret);
print "[COLOR=red][b]**[/b][/color]$tmp[0][COLOR=red][b]**[/b][/color]\n";

But, when I run this code, the output looks like this:

Code:
[COLOR=red][b]**[/b][/color]Preparing...                ##################################################[COLOR=red][b]**[/b][/color]

How can I catch '[100%]' in the output?

Thanks for your help.
 
print @tmp and see what all of the lines in the array are. I would assume it's in there somewhere.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thank you Kevin and Pinkey. And sorry for the delay.

To Kevin, I actually printed '@tmp' and [xxx] is nowhere found.

To Pinkey, yes, I am positive that rpm is printing the [xxx] to the screen. but I just can not catch it in a perl variable.
 
I think what Pinkey means is that it's being printed to STDERR, not STDOUT. So it won't show up in the array, but you will see it on the screen.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top