Posted to tcl by aspect at Tue Sep 30 13:34:23 GMT 2014view raw

  1. log_user 0
  2. spawn /bin/cat /etc/passwd
  3. expect {
  4. ^sys {
  5. # the pattern you want should come first
  6. puts "Found the sys account!"
  7. }
  8. \n {
  9. # fallback pattern
  10. puts "That's not the line I'm looking for!"
  11. exp_continue # exp_continue will restart this expect block
  12. }
  13. }
  14. puts "Done!"
  15.