bash script to ssh and run commands
<p>I want to ssh to a node and run a command there and then exit. This is repeated for all nods. The script is fairly simple</p>

<pre><code>#!/bin/bash
NODES="compute-0-0 compute-0-1 compute-0-2 compute-0-3"
for i in $NODES
do
   ssh $i
   ls -l /share/apps 
   rpm -ivh /share/apps/file.rpm
   exit
done
</code></pre>

<p>But the problem is that, after the ssh, the <code>ls -l</code> command is missed. Therefore, the command prompt waits for an input!</p>

<p>Any way to fix that?</p>

<p>UPDATE:</p>

<p>I modified the loop body as</p>

<pre><code>ssh $i &lt;&lt;END
 ls -l /share/apps
 exit
END
</code></pre>

<p>But I get</p>

<pre><code>./lst.sh: line 9: warning: here-document at line 5 delimited by end-of-file (wanted `END')
./lst.sh: line 10: syntax error: unexpected end of file
</code></pre>