sagibeli has asked for the wisdom of the Perl Monks concerning the following question:

hello, i know that i can use unix commands in perl using: system() or writing the command between `` and when i running the script, the commands are shown in the terminal window. i wanted to know how can i prevent those command from shown in that window? thank you, sagi

Replies are listed 'Best First'.
Re: unix command in perl
by jettero (Monsignor) on Sep 25, 2007 at 12:20 UTC
    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

      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
Re: unix command in perl
by graff (Chancellor) on Sep 25, 2007 at 13:21 UTC
    Show us some code that demonstrates the problem. Try using an example that would do the same thing on any unix/linux system (that is, don't make it depend on some particular data file in your home directory).