0

I am getting zipping error when I try to open the zip file. I want to capture that error msg. Plz help me in doing that. I need the solution in perl.

eg::

gzcat zipfile.gz

gzip: zipfile.gz: unexpected end of file

I want to capture "unexpected end of file" into a variable.

How can I do that in PERL??

Thanks in advance.

Leeor
  • 19,260
  • 5
  • 56
  • 87
user2899676
  • 123
  • 1
  • 6

2 Answers2

0

I think this module can help:

http://metacpan.org/pod/IO::CaptureOutput

szabgab
  • 6,202
  • 11
  • 50
  • 64
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56
0

You need to redirect your stderr output . One way to do this (might depend on your shell though), is -

my $res = `mycommand 2>&1`;
print "output + errors: $res\n"

There are also other suggestions here - How do you capture stderr, stdout, and the exit code all at once, in Perl?

Community
  • 1
  • 1
Leeor
  • 19,260
  • 5
  • 56
  • 87