gawk 3.0.3 nt pipe bug? 
Author Message
 gawk 3.0.3 nt pipe bug?

I am unable to get this simple command to work
under Windows NT (3.51 and 4.0)

        echo "hi" | gawk "{print $1}"

It fails with

gawk: cmd. line:2: fatal: can't stat fd 0 (Function not implemented)

Any suggestions?

Thanks,
David

David Hewitt
Edbro Software Inc.



Tue, 18 Jan 2000 03:00:00 GMT  
 gawk 3.0.3 nt pipe bug?


% I am unable to get this simple command to work
% under Windows NT (3.51 and 4.0)
%
%       echo "hi" | gawk "{print $1}"
%
% It fails with
%
% gawk: cmd. line:2: fatal: can't stat fd 0 (Function not implemented)
%
% Any suggestions?

Stop using windows NT? Seriously, the trouble is that " doesn't work the same way
in NT's shell as it does in most unix shells. gawk expects its first argument
to be a script and its other arguments to be file names, but i this case the
first argument is
 "{print
and the second argument is
 $1}"

you could put your script in a file and included it with -f, or you could
aquire an alternate shell (bash, pdksh, 4dos/nt, etc).
--

Patrick TJ McPhee
East York  Canada



Wed, 19 Jan 2000 03:00:00 GMT  
 gawk 3.0.3 nt pipe bug?



: % I am unable to get this simple command to work
: % under Windows NT (3.51 and 4.0)
: %
: %     echo "hi" | gawk "{print $1}"
: %
: % It fails with
: %
: % gawk: cmd. line:2: fatal: can't stat fd 0 (Function not implemented)
: %
: % Any suggestions?

: Stop using windows NT? Seriously, the trouble is that " doesn't work the same way
: in NT's shell as it does in most unix shells. gawk expects its first argument
: to be a script and its other arguments to be file names, but i this case the
: first argument is
:  "{print
: and the second argument is
:  $1}"

: you could put your script in a file and included it with -f, or you could
: aquire an alternate shell (bash, pdksh, 4dos/nt, etc).
: --

but even under unix    this statement
awk "{print $1}"
can have bizarre results

I do not know if NT's shell supports the same quoting mechanisms
but just try single quotes:
gawk '{print $1}'

--
*what the h[e,a]ck? it's -grg-*



Wed, 19 Jan 2000 03:00:00 GMT  
 gawk 3.0.3 nt pipe bug?

Quote:



> : % I am unable to get this simple command to work
> : % under Windows NT (3.51 and 4.0)
> : %
> : %     echo "hi" | gawk "{print $1}"
> : %
> : % It fails with
> : %
> : % gawk: cmd. line:2: fatal: can't stat fd 0 (Function not implemented)
> : %
> : % Any suggestions?

> : Stop using windows NT? Seriously, the trouble is that " doesn't work the same way
> : in NT's shell as it does in most unix shells. gawk expects its first argument
> : to be a script and its other arguments to be file names, but i this case the
> : first argument is
> :  "{print
> : and the second argument is
> :  $1}"

> : you could put your script in a file and included it with -f, or you could
> : aquire an alternate shell (bash, pdksh, 4dos/nt, etc).
> : --

> but even under unix    this statement
> awk "{print $1}"
> can have bizarre results

> I do not know if NT's shell supports the same quoting mechanisms
> but just try single quotes:
> gawk '{print $1}'

Single quotes do not work with gawk in NT or OS/2.  Double quotes do
work as expected in both NT and OS/2.

The problem still exists if the command is

echo "hi" | gawk -f foo.awk

where foo.awk is simply {print $1}

It appears to be a bug in the NT port of gawk.  Possibly the RSX (?)
stuff.

Thanks for both your comments,

David (also in East York)



Sat, 22 Jan 2000 03:00:00 GMT  
 gawk 3.0.3 nt pipe bug?

Quote:



> > % [...simple command to work under Windows NT (3.51 and 4.0)
> > %     echo "hi" | gawk "{print $1}"
> > %
> > % It fails with
> > % gawk: cmd. line:2: fatal: can't stat fd 0 (Function not implemented)

> > [..] trouble is that "doesn't work the same way in NT's shell as it does in
> > most unix shells. gawk expects its first argument to be a script and its
> > other arguments to be file names, but i this case the first argument is
> >  "{print
> > and the second argument is
> >  $1}"

> This may not be quite right.  I don't use NT, but command.com under
> DOS and cmd.exe under OS/2 and all common Unix shells will not
> separate in this fashion.  However, many shells distinguish between
> the single and double quote characters, and "$1" will be very different
> from '$1' in these shells.

> In short,

>    gawk "{print $1}"

> is often correct under DOS (and single quotes may fail), but

>    gawk '{print $1}'

> would be appropriate under Unix-like shells (to prevent the expansion
> of $1).

> Finally, if there is a problem with the original example, the OS/2,
> Win32, and DOS maintainers welcome bug reports. I cannot reproduce the
> trouble on Win-95 with any of the djgpp, vcWin32, or MSC versions.  We
> need information on how gawk was compiled, and detailed information
> about the test environment (shell, etc.).  If this is the Cygnus gawk,
> you should followup with them.

Darrel,

I didn't think to try under Win 95, but it DOES work there.

This indeed looks like a bug under NT. I am just using the native NT
shell 'CMD.EXE'.  The even simpler command

echo hi | gawk {print}

 also fails under NT.  This NOT a problem with argument quoting, shell
handling etc.  It is a problem with the pipe support under NT.  The
command

echo hi | gawk -f foo.awk

where foo.awk is defined appropriately also fails with the same error.

gawknt.exe - fails under nt, works under 95.
gawk16.exe - works under OS/2, works under NT (via 16bit os2 support)
gawk32.exe - works under OS/2

I don't know how it was compiled etc.  I got the file GNUAWK.ZIP from
ftp://ftp.leo.org/pub/comp/os/os2/leo/gnu/script/gnuawk.zip
June 26, 1997 1383052 bytes.  It contained all 3 executables.

I've worked around this bug (or can use gawk16.exe) for the moment.

Thanks,
David



Tue, 25 Jan 2000 03:00:00 GMT  
 gawk 3.0.3 nt pipe bug?


Quote:
>>:% I am unable to get this simple command to work
>>:% under Windows NT (3.51 and 4.0)
>>:%
>>:%     echo "hi" | gawk "{print $1}"
>>:%
>>:% It fails with
>>:%
>>:% gawk: cmd. line:2: fatal: can't stat fd 0 (Function not implemented)
>>:
>>: [...] trouble is that " doesn't work the same way in NT's shell as it does
>>: in most unix shells. gawk expects its first argument to be a script and its
>>: other arguments to be file names, but i this case the first argument is
>>:  "{print
>>: and the second argument is
>>:  $1}"

This depends on the shell.  For example, quoting in 4dos is somewhat
closer to Unix, and would not separate as above.

Quote:
>>: you could put your script in a file and included it with -f, or you could
>>: aquire an alternate shell (bash, pdksh, 4dos/nt, etc).

I don't use NT, but gawk under OS/2, Win32, and DOS (compiled from the
supplied pc/Makefile) should understand the quoting used above.

Quote:
>> but even under unix    this statement
>> awk "{print $1}"
>> can have bizarre results

True, but the "bizarre results" come from the unexpected expansion of
$1.

Quote:
>> I do not know if NT's shell supports the same quoting mechanisms
>> but just try single quotes: gawk '{print $1}'

This will work with some combinations of shells and gawk.

Quote:
> Single quotes do not work with gawk in NT or OS/2.  Double quotes do
> work as expected in both NT and OS/2.

It's more complicated than this.  Under DOS and OS/2, much of the
handling of command-lines is the responsibility of the application
rather than the shell.  DJGPP gawk (and OS/2 and DOS gawk compiled
with Stewartson's setargv) will understand single-quote quoting.
Single quotes also work as expected if a suitable unix-like shell is
used (since the shell then does the handling).

Quote:
> The problem still exists if the command is echo "hi" | gawk -f foo.awk
> where foo.awk is simply {print $1}  It appears to be a bug in the NT port
> of gawk.  Possibly the RSX (?) stuff.

We need to know more than this, since "RSX stuff" could apply to more
than one version (emxnt and emxbnd in pc/Makefile).  I suspect that
you are using Rommel's gawknt.exe, but I do not have a test
environment for this exe.

Although the GNU versions are preferred, if you need a Win32 gawk, you
could try the version built with Visual C in the GNUish collection
(http://www.dms.auburn.edu/gnuish).  If you only need a gawk which
understands long filenames on Windows-95, then you could try the djgpp
version (also in the GNUish collection).

I will followup with Rommel on this, but more details would be very
helpful (version, who/how built, shell, etc.).

--



Thu, 27 Jan 2000 03:00:00 GMT  
 gawk 3.0.3 nt pipe bug?




% > Single quotes do not work with gawk in NT or OS/2.  Double quotes do
% > work as expected in both NT and OS/2.
%
% It's more complicated than this.  Under DOS and OS/2, much of the
% handling of command-lines is the responsibility of the application
% rather than the shell.

It's not really all that complicated. Different shells have different
command-line semantics. If an application wants to do something that
isn't covered by the command-line semantics, it's always the application's
responsibility to handle it. I'm sure I've had a problem with double
quotes not working in a win32 environment, but maybe it was windows 95.

% > The problem still exists if the command is echo "hi" | gawk -f foo.awk
% > where foo.awk is simply {print $1}  It appears to be a bug in the NT port
% > of gawk.  Possibly the RSX (?) stuff.

I've had problems with IO redirection in NT, which are too complicated
for me to go into here. Can you redirect anything into gawk? How about
dir, or an executable that writes to stdout? If an executable works,
but shell commands don't I'd blame the shell. Otherwise blame your gawk
port or its installation, since I know I've piped program output into
quite a few applications.

--

Patrick TJ McPhee
East York  Canada



Thu, 27 Jan 2000 03:00:00 GMT  
 gawk 3.0.3 nt pipe bug?

I thought that I had canceled my earlier posting, but I see that it

to the main problem (gawk-for-NT compiled with emx + rsxnt may have
trouble with input from a pipe), but I had said:

  command.com under DOS and cmd.exe under OS/2 and all common Unix shells
  will not separate [quote-delimited arguments]

This is incorrect.  I use 4dos, where the statement is at least mostly
correct.  Sorry.

Back to the main point:

Quote:
> gawknt.exe - fails under nt, works under 95.

In my tests, gawknt failed completely on Win-95, so something odd is
happening.  Rommel remarks that the breakage differs between rsxnt
1.30 and 1.31, and with 1.31 "the end of stdin is flagged as broken
pipe when stdin is a pipe."  A report was filed with the rsxnt author.

Quote:
> gawk16.exe - works under OS/2, works under NT (via 16bit os2 support)

I don't use NT, but gawk16 is a bound OS/2 and DOS program.  I've been
told that NT runs console 16bit OS/2 programs, but I wonder if
bound programs are viewed as DOS programs by NT.

Quote:
> gawk32.exe - works under OS/2

> I don't know how it was compiled etc.  I got the file GNUAWK.ZIP from
> ftp://ftp.leo.org/pub/comp/os/os2/leo/gnu/script/gnuawk.zip
> June 26, 1997 1383052 bytes.  It contained all 3 executables.

This is Rommel's collection.  He's the OS/2 gawk coordinator.

Quote:
> I've worked around this bug (or can use gawk16.exe) for the moment.

Thanks for the report.  Until this gets fixed, the Visual C Win32
version in the GNUish Project <http://www.dms.auburn.edu/gnuish> could
also provide a workaround.  (The djgpp version has received more testing,
but it only understands long filenames on Win-95, not NT.)

--



Mon, 31 Jan 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Gawk bug, gawk won't nawk.

2. Pipe errors ignored on NT - bug or feature

3. looking for windows NT/2000 binary for gawk 3.1.1 (or better)

4. NT gawk question

5. Pb with Gawk on NT

6. Looking for NT awk/gawk

7. GAWK 2.15.6 for Windows NT/95, DOS32

8. gawk for 95/NT

9. bug in gawk? (found in 3.0.4)

10. Bug in GAWK 3.1.1?

11. Gawk for win32 slower than Gawk for Dos_32?

12. bug in gawk 3.1.1?

 

 
Powered by phpBB® Forum Software