wtho@cgcha.UUCP (Tom Hofmann) (08/18/87)
I've just had a strange experience with shell escapes within piped programs. E.g. I called ls | more and typed !mail <address> at the "more" prompt. But instead of being prompted for "Subject:" and entering text (as I expected), the rest of the listing to be displayed was mailed to <address>, and the "more" prompt returned. The reason, as I think, is that standard input of "more" is not the terminal but the pipe, and therefore the standard input of the invoked program is that pipe as well. Therefore "mail" reads from the pipe and not from the terminal. I tried it both on a SUN and a CADMUS and got the same (strange) result. I made another test using "pg" (System V) instead of "more", and this time I got the expected behavior on both machines. My question: Shouldn't shell escapes redirect the input (and output) to the terminal? Tom Hofmann CIBA-GEIGY AG Scientific Computer Center P.O. Box Tel. +41 61 372059 CH-4002 Basel Switzerland uucp: ...!mcvax!cgcha!wtho
mpl@sfsup.UUCP (M.P.Lindner) (08/21/87)
In article <510@cgcha.UUCP>, wtho@cgcha.UUCP writes: > My question: Shouldn't shell escapes redirect the input (and output) > to the terminal? Yes and no. In general, it shouldn't redirect the standard input/output of the command. However, here is a case where the shell escape is invoked *not* by the standard input of the program (the listing) but by the user (on the terminal). I think "more" should connect the input/output of the command to the I/O stream it read the shell escape on in the first place. Mike Lindner ...!attunix!mpl
robertd@ncoast.UUCP (Rob DeMarco) (08/23/87)
In article <510@cgcha.UUCP> wtho@cgcha.UUCP (Tom Hofmann) writes: >I've just had a strange experience with shell escapes within >piped programs. E.g. I called > > ls | more > >and typed > > !mail <address> > >at the "more" prompt. But instead of being prompted for "Subject:" >and entering text (as I expected), the rest of the listing to be >displayed was mailed to <address>, and the "more" prompt returned. >The reason, as I think, is that standard input of "more" is not >the terminal but the pipe, and therefore the standard input of the >invoked program is that pipe as well. Therefore "mail" reads from >the pipe and not from the terminal. I tried it both on a SUN and >a CADMUS and got the same (strange) result. I made another test >using "pg" (System V) instead of "more", and this time I got the >expected behavior on both machines. > >My question: Shouldn't shell escapes redirect the input (and output) >to the terminal? > >Tom Hofmann >CIBA-GEIGY AG >Scientific Computer Center >P.O. Box Tel. +41 61 372059 >CH-4002 Basel >Switzerland uucp: ...!mcvax!cgcha!wtho I tryed this under Unix System III using "mailx" and got: No message !?! I tried it again from normal shell and hitting CTRL-D with no message body and got the same thing. Apparently: ls -a | more !mailx robertd Doesn't send ANYTHING to the message body. [> Rd -- North Coast Computer Resources(ncoast) - 216-781-6201 (or 781-6202) UUCP:decvax!cwruecmp!ncoast!robertd Sysop: NEODG (login "sbbs")