title: Expect script to verify login working
body: <p>My company uses powerbroker identity service to bridge authentication between AD and Linux systems.</p>
  
  <p>I am trying to write an expect script that I can use to verify that the authentication is working .. .and write the output to a file.  Can anyone help?.. this is going to be used on a huge list of servers..  I don't really know expect so here is what I got so far but not sure how to get it to log.. or to create a case statement where it says if server is good or not...</p>
  
  <pre><code>#!/usr/bin/expect -f
  set timeout -1
  set ip [lindex $argv 0]
  set user XXXXXX
  set password XXXXXXX
  spawn ssh "$user\@$ip"
  expect -exact ":"
  send "$password\r";
  expect "$"
  send -- "\r"
  send -- "hostname ; date\r"
  expect "$"
  send -- "exit\r"
  </code></pre>