IMHO, understandong [icode]|[\icode] (aka, the "pipe") is fundamental for using UNIX. As is understanding standard-input and -output.
While this is a bit of a simplification,
commandA | commandB is functionally equivalent to
commandA > tempfile; commandB < tempfile; rm tempfile, but without the overhead of creating, reading, writing, and removing
tempfile. Also, both commands are run simultaneously.
So for:
Quote:
Originally Posted by
PAKumar
What is the exact different between both:
1C) echo D | ./testconnectiontoDB
2C) ./testconnectiontoDB | echo D
You are correct in:
Quote:
Originally Posted by
PAKumar
As per my knowledge by using (1C) D option will be taken and it will get posted to the script it is running right as part of execution? (If I am wrong correct me ..)
Although I would say:
D\n (the character "D" followed by a newline character) is written to stdout of
echo, which is read by
testconnectDB.
Quote:
Originally Posted by
PAKumar
In Second option (2C) .. why it wont work in the sameway ..
As per the
echo manual page, only output is sent to stdout, nothing is ever read in. So what ever was generated by
./testconnectiontoDB was lost.
Hope this helps.
-- MDL