Re: Strange shell script behaviour



Richard Wright wrote:
Hi,
I've posted this up on the Sun forums but no joy, so what do you make
of this;

I'm having problems with rsh inside a shell script.
Look at the following script;

cat /etc/hosts | while read LINE
do
echo reading $LINE
done


This works fine - each line is echoed out to the screen.

Now if I add in a rsh;

cat /etc/hosts | while read LINE
do
echo reading $LINE
rsh `hostname` ls
done



It only processes the first line and then quits the loop, although the
rsh line works fine.
Can anyone explain why and/or give me a workaround?
I need to read a line at a time as I process each line through awk in
my real script.
Note that the rsh doesn't really do much, it just rsh's to itself and
executes an ls (which outputs to the screen no probs).
Also, /etc/hosts is just there as an example. Any file has the same
result.

ta..

If you must use rsh, "rsh -n" to keep remote process from consuming
the remaining input from stdin.
.



Relevant Pages

  • Strange shell script behaviour
    ... I'm having problems with rsh inside a shell script. ... cat /etc/hosts | while read LINE ... echo reading $LINE ...
    (comp.unix.solaris)
  • Re: no stdin so how do I pass variables instead?
    ... > There are tabs in the initial output. ... > stuff to format it the way the $volsv script needs it presented. ... >>the rsh and the next command. ... I noticed something while running this in debug mode (is -x called debug ...
    (comp.unix.shell)
  • Re: Dealing with SIGHUP
    ... >>commands after the 'rsh' in the shell script were skipped.) ... > This will only call rsh once, for the first line in filename, because rsh ...
    (comp.unix.solaris)
  • Re: Probelm when rsh to Solaris 8
    ... I missed two lines in php code. ... This is a very simplified test script. ... The rsh should be the one came with the W2K ... >>CMD window popped up and stayed there until CGI timeout. ...
    (comp.lang.php)
  • Re: Dealing with SIGHUP
    ... >commands after the 'rsh' in the shell script were skipped.) ... This will only call rsh once, for the first line in filename, because rsh ...
    (comp.unix.solaris)