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

Re: A small doubt



On Mon, Jul 23, 2001 at 10:34:27AM +0530, shyamk@eth.net wrote:
> Good Morning/Evening  to all,
>          I guess that it is standard in Unixes that :
> 0 : STDIN : keyborad
> 1 : STDOUT : monitor
> 2 : STDERR : error output device

Those file descriptors, yes.

> If this much can be accepted , and this is true for Linux verssions , too ,
> then how come I am given an error by my Linux machine for example :
> [shyam @shyam shyam] cat < 0
> Sample
> ^d

For the same reason it won't work on any other Unix version?

You asked to redirect input from a file named '0'.  It's pointless to
redirect standard input to come from standard input, so I have no idea
what the point of this exercise is supposed to be...

> Can not open 0 : No file or directory
> [shyam @shyam shyam]
> 
> The same occurs for 1 (STDOUT) also.

No.  That works fine.

This works:
    cat > foo

Which takes stdout, and sends it to the file named 'foo'.

I think the core of your problem is that you have the idea that STDIN is
the keyboard.  It is not.  Nor is STDOUT the monitor.  It isn't.

Both are -often- pointed to those locations, but that doesn't mean
they need to be, nor, perhaps, is it even the most common place for
them.

>From the perspective of cat, it reads from file 0 (stdin) until it gets
an end of file, and meanwhile writes to file 1 (stdout).  The shell lets
you redirect those as you see fit.  'man bash' and read the sections on
redirecting input and output.

-- 
CueCat decoder .signature by Larry Wall:
#!/usr/bin/perl -n
printf "Serial: %s Type: %s Code: %s\n", map { tr/a-zA-Z0-9+-/ -_/; $_ = unpack
'u', chr(32 + length()*3/4) . $_; s/\0+$//; $_ ^= "C" x length; } /\.([^.]+)/g; 



Reply to: