On 7/19/11 Tue Jul 19, 2011 12:14 PM, "Tessio Fechine" <oiss...@gmail.com> scribbled:
> 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? You can use a shell process to discard STDERR messages (untested): my $cmd = "useradd -m $account 2> /dev/null"; my $result = system($cmd); You could do the same by writing a shell script to redirect STDERR and call that from your Perl program. You can also use the IPC::Open3 module to capture STDERR. See 'perldoc IPC::Open3' for examples. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/