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
  • 18,457
  • 5
  • 52
  • 82
user2899676
  • 113
  • 1
  • 6

2 Answers2

0

I think this module can help:

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

szabgab
  • 6,024
  • 11
  • 48
  • 61
Lajos Veres
  • 13,452
  • 7
  • 42
  • 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
  • 18,457
  • 5
  • 52
  • 82