home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / question / 13047 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.1 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!doc.ic.ac.uk!uknet!icsbelf!ianmcd
  2. From: ianmcd@icsbelf.co.uk (Ian McDevitt)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: How to handle data from stdin in a sh script
  5. Message-ID: <BxAs3F.t77@icsbelf.co.uk>
  6. Date: 6 Nov 92 13:57:15 GMT
  7. References: <5725@esf.esf.de>
  8. Organization: ICS Computing Group Ltd., Belfast
  9. Lines: 26
  10. X-Newsreader: TIN [version 1.1 PL6]
  11.  
  12. Klaus Wicovsky (klaus@helsinkiesf.de) wrote:
  13. (> 
  14. (> Here is the problem: I would like to pipe data into a sh script and still be able to interact with the sh script (ask questions to the user). 
  15. ...
  16. (> Any ideas?
  17. (> 
  18.  
  19. Try this, I can't guarantee it'll work on every system
  20. but I believe /dev/tty is fairly standard.
  21.  
  22. prog.sh:
  23.     read stdin1
  24.     echo "Standard input is $stdin1"
  25.  
  26.     echo  -n "Please confirm:"
  27.     read conf < /dev/tty
  28.  
  29.     read stdin2
  30.     echo "Next line of standard input is $stdin2"
  31.  
  32. I'll leave it up to you to get the piped input bits correct.
  33. Typing 'ls |prog.sh' seemed to work ok for me.
  34. Good luck!
  35. -- 
  36.         Ian McDevitt, ICS Computing Group Ltd, Belfast. [Tel: (+44) 232 833422]
  37.                  ianmcd@icsbelf.co.uk
  38.