Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.networking > #2068

Re: Mental-model of multiprocessing?

From "Chris F.A. Johnson" <cfajohnson@gmail.com>
Newsgroups comp.os.linux.networking, comp.os.linux.misc
Subject Re: Mental-model of multiprocessing?
Date 2013-03-29 18:55 -0400
Organization A noiseless patient Spider
Message-ID <9oih2a-s2t.ln1@cfa.johnson> (permalink)
References <rovg2ax8ap.ln2@news.roaima.co.uk> <kj500f$qll$1@dont-email.me>

Cross-posted to 2 groups.

Show all headers | View raw


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, <http://cfajohnson.com>
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Back to comp.os.linux.networking | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Mental-model of multiprocessing? Avoid9Pdf@gmail.com - 2013-03-27 11:13 +0000
  Re: Mental-model of multiprocessing? Joe Beanfish <joebeanfish@nospam.duh> - 2013-03-27 14:02 +0000
    Re: Mental-model of multiprocessing? Richard Kettlewell <rjk@greenend.org.uk> - 2013-03-27 14:13 +0000
      Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-27 14:35 +0000
        Re: Mental-model of multiprocessing? Chris Davies <chris-usenet@roaima.co.uk> - 2013-03-27 15:30 +0000
          Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-27 18:57 +0000
        Re: Mental-model of multiprocessing? Richard Kettlewell <rjk@greenend.org.uk> - 2013-03-27 21:15 +0000
          Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-27 21:36 +0000
          Re: Mental-model of multiprocessing? Aragorn <stryder@telenet.be.invalid> - 2013-03-28 06:56 +0100
      Re: Mental-model of multiprocessing? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-03-27 21:47 +0000
    Re: Mental-model of multiprocessing? Avoid9Pdf@gmail.com - 2013-03-29 14:28 +0000
      Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-29 15:32 +0000
        Re: Mental-model of multiprocessing? J G Miller <miller@yoyo.ORG> - 2013-03-29 22:36 +0000
      Re: Mental-model of multiprocessing? Chris Davies <chris-usenet@roaima.co.uk> - 2013-03-29 17:31 +0000
        Re: Mental-model of multiprocessing? Avoid9Pdf@gmail.com - 2013-03-29 21:10 +0000
          Re: Mental-model of multiprocessing? "Chris F.A. Johnson" <cfajohnson@gmail.com> - 2013-03-29 18:55 -0400
            Re: Mental-model of multiprocessing? Unknown <dog@gmail.com> - 2013-03-30 06:01 +0000
          Re: Mental-model of multiprocessing? Chris Davies <chris-usenet@roaima.co.uk> - 2013-03-30 21:28 +0000
          Re: Mental-model of multiprocessing? Joe Beanfish <joebeanfish@nospam.duh> - 2013-04-01 15:32 +0000
            Re: Mental-model of multiprocessing? Unknown <dog@gmail.com> - 2013-04-03 08:00 +0000
              Re: Mental-model of multiprocessing? Joe Beanfish <joebeanfish@nospam.duh> - 2013-04-08 14:47 +0000
            Re: Mental-model of multiprocessing? Unknown <dog@gmail.com> - 2013-04-03 08:02 +0000

csiph-web