home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!doc.ic.ac.uk!uknet!icsbelf!ianmcd
- From: ianmcd@icsbelf.co.uk (Ian McDevitt)
- Newsgroups: comp.unix.questions
- Subject: Re: How to handle data from stdin in a sh script
- Message-ID: <BxAs3F.t77@icsbelf.co.uk>
- Date: 6 Nov 92 13:57:15 GMT
- References: <5725@esf.esf.de>
- Organization: ICS Computing Group Ltd., Belfast
- Lines: 26
- X-Newsreader: TIN [version 1.1 PL6]
-
- Klaus Wicovsky (klaus@helsinkiesf.de) wrote:
- (>
- (> 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).
- ...
- (> Any ideas?
- (>
-
- Try this, I can't guarantee it'll work on every system
- but I believe /dev/tty is fairly standard.
-
- prog.sh:
- read stdin1
- echo "Standard input is $stdin1"
-
- echo -n "Please confirm:"
- read conf < /dev/tty
-
- read stdin2
- echo "Next line of standard input is $stdin2"
-
- I'll leave it up to you to get the piped input bits correct.
- Typing 'ls |prog.sh' seemed to work ok for me.
- Good luck!
- --
- Ian McDevitt, ICS Computing Group Ltd, Belfast. [Tel: (+44) 232 833422]
- ianmcd@icsbelf.co.uk
-