Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!veritas!amdcad!dgcad!dg-rtp!hunt From: hunt@dg-rtp.rtp.dg.com (Greg Hunt) Newsgroups: comp.unix.questions Subject: Re: Can sh or csh do this VMS DCL trick?? Message-ID: <1991Apr28.020109.1668@dg-rtp.dg.com> Date: 28 Apr 91 02:01:09 GMT References: Sender: hunt@hobbit (Greg Hunt) Reply-To: hunt@dg-rtp.rtp.dg.com Distribution: comp Organization: Data General Corp., Research Triangle Park, NC Lines: 56 In article , davis@pacific.mps.ohio-state.edu ("John E. Davis") writes: > > In VMS DCL I can do: > > $ create post_news.txt > $ deck > > Hi, > > In VMS DCL I can do: > > .... etc.... > $ eod > $ exit > > In other words, text following `$ deck' is treated as lines to be fed into > the standard input of the previous command (create in this case). Finally, > the `$ eod' terminates input and control is passed back to the DCL command > procedure. How can I simulate this behavior in csh or sh? Solutions > requiring two files are not acceptable. Sure, it can be done in either csh or sh the same way, using what is called a "here" document, like this in a script: cat << EOD > post_news.txt In csh or sh scripts you can use a "here" document. After the text, put the "word" you put after the "<<" on a line by itself starting column 1. That marks the end of the document that is right "here" in the script. EOD The shell puts the text into a temporary file that it points the command's standard input to. If you want the text from the user running the script, then just redirect the standard input to the terminal instead, like this in a script: cat < /dev/tty > post_news.txt When the user is done typing, he or she enters ^D (control-D), which indicates end-of-file. Take a look at the input and output redirection portions of the sh and csh man pages for more details. Gee, and only one file used, too .... Enjoy! -- Greg Hunt Internet: hunt@dg-rtp.rtp.dg.com DG/UX Kernel Development UUCP: {world}!mcnc!rti!dg-rtp!hunt Data General Corporation Research Triangle Park, NC, USA These opinions are mine, not DG's.