home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / shell / 5060 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  1.9 KB

  1. Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!ariel!davidsen
  2. From: davidsen@ariel.crd.GE.COM (william E Davidsen)
  3. Newsgroups: comp.unix.shell
  4. Subject: rsh terminates while loop
  5. Message-ID: <1992Dec14.202147.5077@crd.ge.com>
  6. Date: 14 Dec 92 20:21:47 GMT
  7. Sender: usenet@crd.ge.com (Required for NNTP)
  8. Reply-To: davidsen@crd.ge.com (bill davidsen)
  9. Organization: GE Corporate R&D Center, Schenectady NY
  10. Lines: 43
  11. Nntp-Posting-Host: ariel.crd.ge.com
  12.  
  13.  
  14.   A friend just brought this one in, and I've simplified it down to
  15. something you can type in and ponder. He wants to call a shell script
  16. with a filename, and read two variables per line from the file, and
  17. execute a command on a remote machine using rsh, including the two
  18. values read off a line.
  19.  
  20.   It appears that the rsh does /something/ which wipes out the stdin of
  21. the while loop. What I would like to understand is what's happening (I
  22. already have an ugly but functional workaround).
  23.  
  24. $ cat y.tmp
  25. qx1 -a
  26. qx2 -a
  27. danqx -l
  28. $ cat x.tmp
  29. #!/bin/sh
  30. while read host flags
  31. do
  32.  result=`rsh $host uname $flags`
  33.  echo "$host: $result"
  34. done
  35. $ ./x.tmp < y.tmp
  36. qx1: qx1
  37. $
  38.  
  39. Note that after reading a single line from the file the while loop ends.
  40. Any command other than rsh does not cause this, and if you use ksh you
  41. get an illegal IOCTL fault (under SunOS).
  42.  
  43. This fails under SunOS and HP-UX, but works with SCO ODT at a minimum,
  44. supposedly fails on virtually anything with a form of rsh (aka rcmd,
  45. remsh, etc) based on BSD code. I *think* it's a bug in rsh in the
  46. redirecting of the i/o to sockets and pulling it back, but I don't
  47. swear to it. 
  48.  
  49. If anyone has some words of wisdom on this I'd love to hear them, it
  50. really should be valid as posted. I'll try to get a chance to test on a
  51. few other machines in the next few days.
  52.  
  53. --
  54. bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
  55.     Keyboard controller has been disabled, press F1 to continue.
  56.