title: Bash script to SSH to a server and connect to DB
body: <p>I want to test connectivity to DBs via a shell script that will SSH on to a number of boxes and then test the mysql connection. I have SSH keys working so I am not explicitly specifying user@server in the ssh command. The script is not working as i would expect and prompts me for a password but errors and uses the password as a DB name. Can some one please advise?</p>
  
  <pre><code>#!/bin/bash
  
  SERVER_LIST=(172.10.1.1 172.10.1.2 172.10.1.3)
  CONNECTION=172.0.0.10
  USER="username"
  PASS="password"
  
  echo "Testing connectivity... "
  for SERVER in ${SERVER_LIST[@]}
  do
      echo "SSHing to $SERVER"
      ssh $SERVER "mysql -h $CONNECTION -u $USER -p$PASS"
  done
  echo "Finished."
  </code></pre>
  
  <p>After some reading around, should i have a expects command or similar on the password prompt? I have experimented with this to no avail...</p>