title: Error no route to host using expect while reading host user name and passwords from a csv file
body: <p>I writing a script to read user name, password and host info from a file. 
  I then parse this info to get the variables.  I would then like to add these variables to an expect script that reads all the ip address in my file and performs certain commands on the remote devices that I am trying to log into.  The script works when it connects to a known host however What I am seeing is that there is one device that is not up and running and the system promps with the following error. 
  ssh: connect to host 192.168.3.2 port 22: No route to host </p>
  
  <p>the file 
  I would like to do 2 things 
  1. Skip the host and move to the next host
  2. log the host that is down to another file so that I can troubleshoot the network issue to that host.</p>
  
  <p>Please see the script below.  Please any help is greatly accepted. </p>
  
  <pre><code>#! /usr/bin/expect -f
  
  
  
  ## Read the file
  set fid [open /csv_pars/employee1.csv]
  set content [read $fid]
  close $fid
  
  ## Split into records on newlines
  set records [split $content "\n"]
  
  ## Iterate over the records
  foreach rec $records {
  
  ## Split into fields on comma
  set fields [split $rec ","]
  ## Assign fields to variables and print some out...
  lassign $fields\  ipaddr username password
  puts "$ipaddr"
  puts "$username"
  puts "$password"
  
  
  
  
  
  if {$ipaddr == ""} continue
  spawn ssh  -X "$username@$ipaddr"
  sleep 2
  expect "password:"
  
  
  sleep 2
  send  "$pass\r"
  expect  "$"
  send -- "ls -l\r"
  expect "$"
  send -- "exit\r"
  
  
  expect eof
  
  
  
  
  }
  </code></pre>