My script runs this command which always gives three warnings. Is there a way to filter these out?
my $output = `cleartool mktag -view -tag test -reg win_region -host view_server1 -gpath \\\\view_server\\view_directory1\\test.vws/viewstore/view_directory1/test.vws\`
The warnings look something like this:
cleartool: warning: The global pathname "blabla" in the non-default region will not be validated
cleartool: warning: Unable to access "blabla": No such file or directory
cleartool: warning: Storage pathname "blabla" may not reside on host
Assuming the external tool writes to
STDERRyou can tell the shell to redirect that somewhere else. The usual way to do that is to append2> /dev/nullto the command you’re running via the backticks.If you need other warnings and errors then capture
STDERRin a temporary file (see File::Temp for how to safely generate temporary files) by redirecting2> $temp_file_name, read that file with Perl (see File::Slurp or IO::All for easy-to-use one liners for reading files likemy @captured_stderr = read_file($temporary_file_name);), throw away the lines to you not need with Perl’sgrepfunction and output the remaining lines back toSTDERRwithprint STDERR @captured_stderr).