You are here: Foswiki>System Web>Category>DeveloperDocumentationCategory>PerlDoc (2024-12-23, UnknownUser)Edit Attach
 See PublishedAPI for packages intended to be used by Plugin and Contrib authors, or browse all packages.
 See also Developing plugins, Developer's Bible, Technical Overview
On this page:
Very simplistic redirection of STDERR/STDOUT.
Simply avoid any output:
use Foswiki::Util::MuteOut;
sub proc {
    my ($dir) = @_;
    my $rc = system "ls -la $dir";
    print STDERR "RC=", $rc;
}
my $mute = Foswiki::Util::MuteOut->new;
# Nothing will be displayed by proc()
$mute->exec(\&proc, "/etc");
Capture output into files:
my $capture = Foswiki::Util::MuteOut->new(
    outFile => 'stdout.txt',
    errFile => 'stderr.txt',
);
# The output will end up in corresponding files.
$capture->exec(\&proc, "/etc");
Redirections are restored when the object destroyed.
Edit | Attach | Print version | History: r1 | Backlinks | View wiki text | Edit wiki text | More topic actions
Topic revision: r1 - 2024-12-23, UnknownUser
  Copyright © by the contributing authors. All material on this site is the property of the contributing authors.
Copyright © by the contributing authors. All material on this site is the property of the contributing authors. 
 Ideas, requests, problems regarding Foswiki? Send feedback