title: Bash - SSH Multiple commands with delay between them
body: <p>I am trying to connect to a submodule of a router, run some commands on it and save the output to a file. The problem I have is that the submodule requires an username and password and if put all the commands in a single script the username/pass details are sent before the prompt to enter them appears. Is there a way to set a delay between the commands, or run them in batches under the same SSH session?</p>
  
  <p>I used the EOF approach and also having the commands in a separate file (preferred):</p>
  
  <pre><code>ssh user@root &gt; file.log &lt;&lt; EOF
  session slot 1    # command to connect to the subslot. 
                    # a delay of about 3 sec would be required before the    credentials are sent
  slot_username
  slot_password
  command1
  command2
  command3
  exit
  exit
  EOF
  </code></pre>
  
  <p>Also, the second exit should take me out of the router, but it is just ignored. </p>