title: Is it possible to run a script which loops through hosts with rsh/ssh
body: <p>I have tried to run following csh script which ssh to all computers on our network with the purpose of yum installing software passed as arguments.  However, the script fails to continue once I have rsh to another host. Is there a way around this problem?</p>
  
  <pre><code>if ($1 == "")then
      echo -n "Please enter a package to install\n"
      set package=$&lt;
  else set package = $#argv
  endif
  
  set numlines = `cat $NM_HOME/sh_local/nc_network2.txt | grep -v "^#" | fgrep "%" |  wc -l`
  while ($numlines&gt;0)
      set line = `cat $NM_HOME/sh_local/nc_network2.txt | grep -v "^#" | fgrep "%" | tail -$numlines | head -1`
      set host2 = `echo $line | cut -f 1 -d %`
      set where = `echo $line | cut -f 2 -d %`
      if ($host2 == $this_machine) then 
      echo "This is $host2....skipping rsh to this machine"
      echo ""
      goto yum
      endif
      echo ""
      echo "logging into $host2 $where"
      echo ""
      sleep 1
      rsh $host2
      yum:
      echo ""
      echo "Preparing to install $package on $host2"
      sudo yum -y install $package
      if ($host2 == $this_machine) then 
      goto decrement
      else
      logout
      goto decrement
      endif
  
      decrement:
      @ numlines--
  
  end
  </code></pre>