home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / shell / 5084 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.6 KB  |  50 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!merlin!cerberus!cerberus.bhpese.oz.au!Sm
  3. From: Sm@cerberus.bhpese.oz.au (Scott Merrilees)
  4. Subject: Re: rsh terminates while loop
  5. Organization: BHP, Newcastle, Australia
  6. Date: Wed, 16 Dec 1992 01:57:18 GMT
  7. Message-ID: <1992Dec16.015718.14727@cerberus.bhpese.oz.au>
  8. References: <1992Dec14.202147.5077@crd.ge.com>
  9. Sender: news@cerberus.bhpese.oz.au (News System)
  10. Lines: 38
  11.  
  12. davidsen@ariel.crd.GE.COM (william E Davidsen) writes:
  13.  
  14.  
  15. >  It appears that the rsh does /something/ which wipes out the stdin of
  16. >the while loop. What I would like to understand is what's happening (I
  17. >already have an ugly but functional workaround).
  18.  
  19. >$ cat y.tmp
  20. >qx1 -a
  21. >qx2 -a
  22. >danqx -l
  23. >$ cat x.tmp
  24. >#!/bin/sh
  25. >while read host flags
  26. >do
  27. > result=`rsh $host uname $flags`
  28. > echo "$host: $result"
  29. >done
  30. >$ ./x.tmp < y.tmp
  31. >qx1: qx1
  32. >$
  33.  
  34. >Note that after reading a single line from the file the while loop ends.
  35. >Any command other than rsh does not cause this, and if you use ksh you
  36. >get an illegal IOCTL fault (under SunOS).
  37.  
  38. use 'rsh -n' if it works for you, otherwise use 'rsh </dev/null'.
  39.  
  40. What happens is that the local rsh can't know when the remote process need
  41. input, so it gobbles up stdin and passes it to the remote process, thus
  42. using all your input.  If the remote process doesn't use all or any of the
  43. input, then it is lost, because it isn't passed back and reinserted into
  44. stdin.
  45.  
  46. Sm
  47. -- 
  48. Scott Merrilees, BHP Information Technology, Newcastle, Australia
  49. Internet: Sm@bhpese.oz.au   Phone: +61 49 40 2132   Fax: ... 2165
  50.