Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Output to file AND stderr

7 views
Skip to first unread message

Clemens Meier

unread,
Oct 31, 1995, 3:00:00 AM10/31/95
to
In article <jadestar...@netcom.com> jade...@netcom.com (JaDe) writes:

Hello!

> print > "/dev/stderr" works in gawk, and mawk (at least).
>
> Oddly enough this also works under DOS ports of these --
> where I consider it to be an idiom (since DOS doesn't have a
> /dev directory and doesn't have any notion of a device
> node in a directory).

I've always considered it an idiom, and a bad one at that.
There is no "/dev/stderr" (and all the "/dev/*" mentioned
in the gawk manpage) on *nix systems (well at least there's
non with HP--SUX and Linux) and (in io.c) the name of the
file to be opened is checked if it's in a list of all those
"/dev/*"--special names and whether to handle it specially
or not.

IMHO this is confusing, since these ``special'' files look
like real ones existing somewhere in the directory tree,
puzzle people who know that there are no such files (e.g.
MSDOS users who know more than how to unpack Windows) and
will bomb on all awks having `<'/`>' IO--redirection but
not these gnuish special names built in. And if they don't
bomb they'll cause serious pain by creating new or abusing
existing files.

Why couldn't they have used reserved words?

Clemens

--
----------------------------------------------------------------------------
> Wo ist denn der Objoke ??? Clemens Meier
Bei Clemens? Nie!! Ok, ok, aber fast nie. clm...@lili.uni-bielefeld.de
GO C+ UL P- L+>++>+++ 3$ E++>+++ N++ R+>+++ G'''' !tv b++ D f?

bill davidsen

unread,
Oct 31, 1995, 3:00:00 AM10/31/95
to
In article <jadestar...@netcom.com>, JaDe <jade...@netcom.com> wrote:

| Oddly enough this also works under DOS ports of these --
| where I consider it to be an idiom (since DOS doesn't have a
| /dev directory and doesn't have any notion of a device
| node in a directory).

??? Try something like "type filename > /dev/lpt" and you will learn
something new about DOS. Note that I used to do this a few years ago
and don't have a DOS machine handy to try it at this instant, but it
really worked for lpt, con, com1 and com2 at least.

Richard Polunsky

unread,
Oct 31, 1995, 3:00:00 AM10/31/95
to
Apparently this 'feature' has been deleted from DOS 6.22.
When I try: type filename > /dev/lpt
I get: Invalid Switch - /dev


Peter Seebach

unread,
Oct 31, 1995, 3:00:00 AM10/31/95
to
In article <CLMEIER.95...@lili6.lili.uni-bielefeld.de>,

Clemens Meier <clm...@lili6.lili.uni-bielefeld.de> wrote:
>I've always considered it an idiom, and a bad one at that.
>There is no "/dev/stderr" (and all the "/dev/*" mentioned
>in the gawk manpage) on *nix systems (well at least there's
>non with HP--SUX and Linux) and (in io.c) the name of the
>file to be opened is checked if it's in a list of all those
>"/dev/*"--special names and whether to handle it specially
>or not.

There is on NetBSD, which is the One True Unix Other Than V10.

But apart from that, it is a distasteful and bad idiom; certainly
not portable.

-s
--
Peter Seebach - se...@solon.com || se...@intran.xerox.com --
C/Unix proto-wizard -- C/Unix questions? Send mail for help. No, really!
Copyright 1995 Peter Seebach. -- High energy particle theology
The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq

Jeff Dege

unread,
Nov 1, 1995, 3:00:00 AM11/1/95
to
On 31 Oct 1995 19:50:53 -0600, Peter Seebach (se...@solutions.solon.com) wrote:
: In article <CLMEIER.95...@lili6.lili.uni-bielefeld.de>,

: Clemens Meier <clm...@lili6.lili.uni-bielefeld.de> wrote:
: >I've always considered it an idiom, and a bad one at that.
: >There is no "/dev/stderr" (and all the "/dev/*" mentioned
: There is on NetBSD, which is the One True Unix Other Than V10.

So how do you feel about "> /proc/self/fd/2" ?

: But apart from that, it is a distasteful and bad idiom; certainly
: not portable.

--


David Kastrup

unread,
Nov 1, 1995, 3:00:00 AM11/1/95
to
davi...@tmr.com (bill davidsen) writes:

>In article <jadestar...@netcom.com>, JaDe <jade...@netcom.com> wrote:

>??? Try something like "type filename > /dev/lpt" and you will learn
>something new about DOS.

Small chance. You might also try /usr/home/dak/lpt. Guess what? It
will never make a file *anywhere* on the file system with a device name.
So you better *never* name a file you intend to transfer to a DOS
system lpt, prn, nul, com1, com2, or any other lot of device names.
Thgere are a lot of hidden device drivers (things like clock$ or
such), fortunately, they usually have at least a few strange characters
in them, so the chance for inadvertous confusion is smaller.
--
David Kastrup, Goethestr. 20, D-52064 Aachen Tel: +49-241-72419
Email: d...@pool.informatik.rwth-aachen.de Fax: +49-241-79502

Doug Quale

unread,
Nov 1, 1995, 3:00:00 AM11/1/95
to
In article <CLMEIER.95...@lili6.lili.uni-bielefeld.de> clm...@lili6.lili.uni-bielefeld.de (Clemens Meier) writes:
>
> I've always considered it an idiom, and a bad one at that.
> There is no "/dev/stderr" (and all the "/dev/*" mentioned
> in the gawk manpage) on *nix systems (well at least there's
> non with HP--SUX and Linux)

Actually any Linux with /proc has /dev/stderr --

# ln -s /proc/self/2 /dev/stderr

--
Doug Quale
qu...@msn.fullfeed.com

Harris Punyon

unread,
Nov 2, 1995, 3:00:00 AM11/2/95
to
Richard Polunsky (polu...@ICSI.Net) wrote:
: Apparently this 'feature' has been deleted from DOS 6.22.
:
:
:

Harris Punyon

unread,
Nov 2, 1995, 3:00:00 AM11/2/95
to
Try using the '\' backslash instead.

JaDe

unread,
Nov 3, 1995, 3:00:00 AM11/3/95
to
In days of yore (1 Nov 1995 08:43:29 GMT)
David Kastrup (d...@hathi.informatik.rwth-aachen.de) proclaimed:

:polu...@ICSI.Net (Richard Polunsky) writes:

:>Apparently this 'feature' has been deleted from DOS 6.22.


:>When I try: type filename > /dev/lpt
:>I get: Invalid Switch - /dev

:Well, of course we were talking Unix idioms and not paying too close
:attention to all the appropriate DOSisms, like reverse slashes whenever
:you use a wilful tool or some inbuilt pain in DOS.

:Try it with :type filename > \dev\lpt

:or with :type filename > \usr\tmp\con

:or with :type filename > \usr\source\drv\makefile\nul

While we're bandying about DOS idioms here's one
that's actually useful

IF EXIST X:\NUL ECHO Drive X: exists

and: IF EXIST X:\FOO\NUL ECHO Directory X:\FOO exists.

This works for all versions of DOS that I've tested (from
DOS 3.1 through DOS 6.22 and including DR 5, 6 and 7).
It also used to work even with Netware drivers -- however the
introduction of VLM's seems to have broken that. Should still
work for users of NETX, though.


--
/> JaDe | Star <\
/< \|/ >\
*[/////|:::====================- --*-- -=====================:::|\\\\\]*
\< /|\ >/
\> jade...@netcom.com | star...@netcom.com </

S.M.Sabri S.M.Ismail

unread,
Nov 4, 1995, 3:00:00 AM11/4/95
to
d...@hathi.informatik.rwth-aachen.de (David Kastrup) writes:
> Small chance. You might also try /usr/home/dak/lpt. Guess what? It
> will never make a file *anywhere* on the file system with a device name.
> So you better *never* name a file you intend to transfer to a DOS
> system lpt, prn, nul, com1, com2, or any other lot of device names.

Actually it's worse than that. Try /whatever/lpt.xxx, or whatever
other extensions to device names. DOS will just ignore the extensions
and assumes it's a device.

regards,
.sabre
--
sa...@sabri.pc.my ~~\ Information Technology /~~ sa...@hq.jkr.gov.my
+60 (0)10-2184925 (H) \____ in Construction ____/ +60 (0)3-4407776 (O)
~~\ http://corp.jkr.gov.my/jln/people/sabre/sabre.htm /~~
~~~~~~~~\__________ Standard Disclaimer Applies __________/~~~~~~~~

0 new messages