[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Using /dev/stderr vs. >&2



I noticed that a bash script of mine was causing permission errors under
cron, so I had to change it like so:

    --- boxmail.sh  2009/06/30 09:01:46     1.10
    +++ boxmail.sh  2009/07/01 08:01:51
    @@ -167,7 +167,7 @@

     # Echo message to standard error.
     function stderr {
    -    echo "$*" > /dev/stderr
    +    echo "$*" >&2
     }

     # Display warnings on standard error.

I did a little minor testing with cron, and >&2 works while /dev/stderr
doesn't. Now, I know that "/dev/stderr" is a bashism, but since cron is
executing boxmail.sh (with an explicit bash shebang) rather than
executing the code directly, why would the bashism come back with:

    From: Cron Daemon
    To: nospam
    Subject: Cron <nospam> $HOME/bin/boxmail.sh
    Date: Wed,  1 Jul 2009 00:00:02 -0700 (PDT)

    /home/nospam/bin/boxmail.sh: line 170: /dev/stderr: Permission denied

The bash manual doesn't say anything about a requirement that the shell
be interactive to use /dev/stderr, so why is this happening?

-- 
"Oh, look: rocks!"
	-- Doctor Who, "Destiny of the Daleks"


Reply to: