in reply to unix command in perl

my @lines = `ls -al`; shouldn't print anything to the terminal window.

... is the stuff that sneaks through on the stderr pipe? If so you, you can maybe use 2>&1 to deal with it.

-Paul

Replies are listed 'Best First'.
Re^2: unix command in perl
by perlfan (Parson) on Sep 25, 2007 at 13:54 UTC
    Yeah, I was thinking that maybe something was sneaking out via STDERR.

    jettero, post the command you are running and the output that is not getting captured.
      my $chk_user=system("ypmatch $user passwd"); where $user is any username. the output i get in case the username doesn't exist: Can't match key sss in map passwd.byname. Reason: No such key in map. and in case the username exists, i get some details about this user. i don't want the results in any case to be shown in the terminal window. thanks
        Hi sagibeli,

        That's not going to work, if you're trying to capture the text.  If you want to make an assignment, use qx (same as the `...` operator).  When you use system, the return value has a different meaning (it's the program's exit status).

        Why don't you try what jettero suggested? ...

        use strict; use warnings; + my $user = 'root'; my $chk_user = `ypmatch $user password 2>&1`; print "Results of 'ypmatch' for user '$user' => '$chk_user'\n";

        s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/