Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: "Chris F.A. Johnson" Newsgroups: comp.os.linux.networking,comp.os.linux.misc Subject: Re: Mental-model of multiprocessing? Date: Fri, 29 Mar 2013 18:55:37 -0400 Organization: A noiseless patient Spider Lines: 80 Message-ID: <9oih2a-s2t.ln1@cfa.johnson> References: Reply-To: cfajohnson@gmail.com Injection-Info: mx05.eternal-september.org; posting-host="065ad8493d7729407e24fc83c484ecf8"; logging-data="29816"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QSzcAE+Mh8bWZxGw9RvyQ8pl7s9ZELsM=" User-Agent: slrn/0.9.8.1 (Linux) Cancel-Lock: sha1:X6dRwvdq/Ca/6juxx7zfzfpu5P4= Xref: csiph.com comp.os.linux.networking:2068 comp.os.linux.misc:7698 On 2013-03-29, Avoid9Pdf@gmail.com wrote: ... > Has `echo` got an 'input' too? Yes, but it doesn 't read it. > What's the definition of 'attached to'? 'sends output to' or 'reads input from' > Has `pwd` also got a pipeable input? I*t's not 'pipeable', because it doesn 't read it. >> Using these simplified rules you can see that this next command line >> takes the stdout from echo and writes to the stdin of cat. Cat is defined >> to send its inputs to stdout, and that isn't redirected anywhere so it >> appears on your terminal. >> >> echo "hello, world" | cat >> Easy really. >> > Which you would never write [nor echo "hello" | cat | cat | cat ] But you could, and it would work. > But the original code used THIS syntax, and that may be the key > to understanding the code. So then: > cat>/tmp/mesgFile > ( > read line 0<&3 ; echo "$line">$log > case "$line" in 2*) ;; *) echo "QUIT" 1>&3 ; exit 0 ;; esac > echo "HELO $local_name" 1>&3 > ) 3<>/dev/tcp/$smtp_server/25 > > would mean > "stdin [since none is provided]" writeTo /tmp/mesgFile > the sequential output of the bracketed-statements > [which also write to there OWN destinations] > .... ?? > > Does: 3<>/dev/tcp/$smtp_server/25 > mean: let fd3 have input AND output to that-device? Yes. Read the man page: Opening File Descriptors for Reading and Writing The redirection operator [n]<>word causes the file whose name is the expansion of word to be opened for both reading and writing on file descriptor n, or on file descriptor 0 if n is not specified. If the file does not exist, it is created. > *THAT* is the 'fraud'(:-;) !! > Only AFTER it's been used is it defined. The shell parses the line and sets up redirection before executing the command. ... > It would be good if the *nix docos put UP FRONT that > 'it's not parsed sequentially left-to-right'; like computers > work or mathematical theorems are proved. It *is* explained in the man page. > It works like poetry: you must get the whole picture > before interpreting. Yes, that's what the shell does. -- Chris F.A. Johnson, Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)