Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Nov 2006 08:50:34 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Robin Becker <robin@reportlab.com>
Cc:        FreeBSD-Questions <freebsd-questions@freebsd.org>
Subject:   Re: shell test for stdout=stderr
Message-ID:  <4569555A.8010904@infracaninophile.co.uk>
In-Reply-To: <4568CF28.5050407@jessikat.plus.net>
References:  <4568CF28.5050407@jessikat.plus.net>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Robin Becker wrote:
> Is there a way for a shell script to test if 2> is the same as 1>? I
> want to put messages in both when they are connected to different files,
> but would like to avoid duplicating the message when they are the same.

You could try using fstat(1) to print out the open file descriptors from
your process:

    fstat -p $$

and then compare the values in the DEV and INUM columns -- unfortunately
fstat has no way to map back from those device and inode values to
filenames.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       7 Priory Courtyard
                                                      Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey         Ramsgate
                                                      Kent, CT11 9PW


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFaVVg8Mjk52CukIwRCGnjAJ9sJW5msMNxOSHaaDT4TDNu1GsGxwCfSu0L
M65zQRMDNR/XoGxeiYlUGCU=
=U3id
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4569555A.8010904>