Path: utzoo!utgpu!watserv1!watmath!att!att!news.cs.indiana.edu!noose.ecn.purdue.edu!samsung!know!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: why doesn't my usage of "while(<>)" work ? Message-ID: <10437@jpl-devvax.JPL.NASA.GOV> Date: 17 Nov 90 00:36:49 GMT References: <9231@pitt.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 40 In article <9231@pitt.UUCP> al@ee.pitt.edu (Alan Martello) writes: : what is wrong with this example ? I want to rsh to another : machine, process the output of the command, and then : use "while(<>)" just like always. : : any help appreciated, please post (unless embarassing) or mail. : I'm running perl PL 41 on a Sun-3 under SunOS 4.1 : compiled with gcc. : : ******************************************************************* : Alan R. Martello Electrical Engineering Dept. : al@ee.pitt.edu University of Pittsburgh : ******************************************************************* : #! /bin/perl : : # get the host name for the rsh : $host = $ENV{'HOST'}; : : # : # THESE NEXT THREE LINES ARE THE OFFENDING ONES : # why does this program work only when these are : # commented out ? : open(WFH, "rsh $host ls |"); : while () { print; } : close(WFH); : : # : # second while statement should copy stdin to stdout : # : while (<>) { : print; : } : exit; Works fine for me. Could you have something weird in your .cshrc that's trying to do dialog and getting nothing from stdin? Try open(WFH, "rsh $host ls &1 |"); Larry