On Jul 20, 12:45 am, walde.christ...@googlemail.com ("Christian Walde") wrote: > On Tue, 19 Jul 2011 21:14:10 +0200, Tessio Fechine <oiss...@gmail.com> wrote: > > Hello, > > I have a subroutine that uses useradd to create accounts > > > -- > > @cmd = ('useradd', '-m', $account); > > my $result = system @cmd; > > -- > > > but when useradd fails, I need to stop it from sending the error message to > > STDER. > > Is it possible with system? > > > Thanks! > > For an easy and cross-platform solution you can use Capture::Tiny to capture > both STDERR and STDOUT separately and then have your perl code decide what to > do with each. >
Neat solution. (I wonder why the name 'Tiny' rather than... say, IPC::Capture for instance..) Another possibility would IPC::Run : use IPC::Run qw( run timeout ); run \@cmd, \$in, \$out, \$err, timeout( 10 ) or die "cmd err: $?"; -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/