|No such thing as a small change|
Re^3: How to execute external programs from perl scriptby Anonyrnous Monk (Hermit)
|on Feb 04, 2011 at 15:02 UTC||Need Help??|
The latter would be appropriate in case you have to press Enter after typing the respective letter when you do it interactively.
The way this works is essentially as follows (somehwat simplified): each program has three standard handles for I/O: stdin, stdout, stderr (we can forget about stderr for the moment).
When you run a program from the command line "normally" (i.e. without a pipe or redirection) those standard handles are connected to the terminal where your command shell runs in. What you type on the keyboard is forwarded to the program as input, and what the program outputs is displayed in the terminal. When you connect two programs via a pipe
stdout of A is being sent to stdin of program B. The respective handles are also disconnected from the terminal, which means that B no longer gets its input from the keyboard, but from program A (and the output of A is no longer displayed in the terminal).
In your particular case, program A is the command "echo", which simply sends to stdout whatever you pass it as arguments, which then ends up as input for program B (phylib) as if you had typed it on the keyboard. In other words, the idea is simply to make echo send to stdout exactly the same characters that you would have typed interactively otherwise.
Also, program B only reads as many characters as it wants at a time, even if program A has output everything at once. The associated buffering (and blocking of I/O, if needed) is handled behind the scenes by the OS.