al@ee.pitt.edu (Alan Martello) (11/20/90)
In article <10437@jpl-devvax.JPL.NASA.GOV>, lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: |> 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. |> : |> : #! /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 (<WFH>) { 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 </dev/null 2>&1 |"); |> |> Larry Thanks Larry, right guess again! the problem was an interaction (probably in .login querying for a terminal or some such). Anyway, either both of these open statements fixes it (the second one may only be valid on my Sun). open(WFH, "rsh $host ls </dev/null 2>&1 |"); open(WFH, "rsh $host -n ls |"); I haven't decided if this was a subtle mistake or a stupid one... ******************************************************************* Alan R. Martello Electrical Engineering Dept. al@ee.pitt.edu University of Pittsburgh *******************************************************************