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.
I think this module can help:
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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.