in reply to Re^2: how to supress stdout
in thread how to supress stdout

hi
what does this mean?
>/dev/null 2>&1 in the open call? I see two redirects. Can you explain this?

Replies are listed 'Best First'.
Re^4: how to supress stdout
by parv (Parson) on Dec 13, 2008 at 00:07 UTC

    First, standard output is redirected to /dev/null. Assuming 1 is standard output file descriptor & 2 is standard error, standard error is also redirected to the same place as standard output (which is to /dev/null).

    Above will work only when a bourne-like shell (FreeBSD /bin/sh, bash, zsh, etc.) handles the redirection.

      Aren't fd 1 and 2 stdout and stderr by definition?

        Yes, they are.

        As for the assumption in "Assuming 1 is standard output ...", if fd's 1 & 2 have been already closed & opened to some other fd's (before redirection), would fd's 1 & 2 still work for the purpose (of redirection after being redirected)?

      ... and there's me thinking that is only true if the re-direction is done in the shell - perl seems to 'know' how 'proper' re-direction works when done as in this example i.e. in a call to one of the open() functions.

      Maybe it's senility setting in big time ??

      A user level that continues to overstate my experience :-))
        No, Perl doesn't know. open invokes the shell when it sees shell meta characters such as > in the command.