Re: What's the difference pipe vs redirection is the following case case.



In article
<8cc2899f-7b0a-4437-922f-0a8e6141e6f9@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
K-mart Cashier <cdalten@xxxxxxxxx> wrote:

On Jun 21, 6:33 pm, j...@xxxxxxxxxxx (Jens Thoms Toerring) wrote:
K-mart Cashier <cdal...@xxxxxxxxx> wrote:
When I execute party, it brings up a chat line. Ie
m-net% party
Welcome to PARTY!  Type '?' for help:
triluda:  my hero
mickeyd:  are we cheech'n'chongish enough?
When I do the following
m-net% party | /dev/null
zsh: permission denied: /dev/null
I get permission denied.
But when I do something like the following
m-net% party > /dev/null
Welcome to PARTY!  Type '?' for help:
e
The output from party gets redirected to /dev/null
What's the difference between the two? Ie, why do I get permission
denied when I try to pipe party to /dev/null?

Because you can pipe to another process but not a file. '|' is
for connecting the stdout of the process on the left hand side
to the stdin of the process of the right hand side. '>' is for
redirecting the stdout of the left hand side process to a file
on the right hand side. You get permission denied for

m-net% party | /dev/null

because it instructs the shell to start the program /dev/null
but, when the shell tries to do so, it finds that /dev/null
hasn't the executable bit set (which makes sense since /dev/null
isn't an executable but just a "file", not a program).


Maybe I'm overcomplicated this a bit, but what's the difference
between an executable, a "file", and a program? I thought an
executable was a program.

A program is stored in a file. The execute permission bit tells the OS
whether it's OK to execute the file as a program. If you try to use a
filename as a command, and it doesn't have the execute bit set, you'll
get a "permission denied" error.

If, for some reason, you set the execute bit on a file that doesn't
contain a program, and try to execute it, you'll get an error that says
something about the file not being in the correct format (the specific
error differs across OSes).

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages