[clue-tech] Error messages that can't be redirected

chris fedde chris at fedde.us
Sat Nov 7 00:08:51 MST 2009


Sometimes programmers decide to write directly to /dev/tty rather than
using stderr and stdout.   But I wanted to investigate this a bit.  So
I went ahead and installed GraphicsMagick to see how it uses IO..

I ran the following:

   script
   strace gm convert
   exit

and then examined the 'typescript' file generated.
there I found most of the output going to stdout:

     write(1, "with an image format name and a c"..., 69) = 69

and some going to stderr:

     write(2, "gm convert: "..., 12 )         = 12

I found no evidence that /dev/tty was being opened or written to.  In
this respect it appears that gm is a normal well behaved posix
program. At least in this respect.

I was also able to demonstrate that the above error message got placed
into a file using simple redirection:

     gm convert 2> bar
 ...
     cat bar
     gm convert: Improper arguments supplied, please see manual.

and with compound redirection:

     gm convert >> bar 2>&1

  ...
     with an image format name and a colon (i.e. ps:imagm convert: Improper
     arguments supplied, please see manual.
     ge) or specify the
  ...

Note that the error text on stderr above is "intermixed" into the
output from stdout.

I think that from this I'll concoude that gm performs as expected and
the effect that you are seeing is caused by some other interaction.

On Fri, Nov 6, 2009 at 9:46 PM, Matt Gushee <matt at gushee.net> wrote:
> Hi folks--
>
> Here's something that's been bugging me for a long time: sometimes I will
> use a command-line program and try to redirect the output, e.g. to a log
> file, and it doesn't work. For example:
>
>  for img in *.jpg; do
>    nice gm convert -resize 160x160 $img thumbs/$img >> resize.log 2>&1
>  done
>
> Nope. I get nothing in my log file. I've tried several variations of this
> command, including piping the output to tee. It just doesn't ever work.
> 'gm', by the way, is GraphicsMagick, a better-performing fork of
> ImageMagick. The same thing happened with ImageMagick, and IIRC with some
> other programs I've used on occasion.
>
> So what's going on here?
>
> --
> Matt Gushee
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://www.cluedenver.org/mailman/listinfo/clue-tech
>


More information about the clue-tech mailing list