Posted to tcl by meissa at Tue Oct 29 20:09:43 GMT 2024view raw

  1. #!/usr/bin/expect
  2.  
  3. set cmd [lrange $argv 2 end]
  4. set timeout [lindex $argv 0]
  5. set password [index $argv 1]
  6.  
  7. set timeout $timeout
  8.  
  9. eval spawn -noecho $cmd
  10. log_user 0
  11. expect {
  12. -nocase -re "^.*password.*: " {
  13. send "$password\r"
  14. #log_user 1
  15. exp_continue
  16. }
  17. timeout { exit 1 }
  18. eof
  19. }
  20. catch wait result
  21. puts [string range "$expect_out(buffer)" 2 end-2]
  22. exit [lindex $result 3]
  23.  

Add a comment

Please note that this site uses the meta tags nofollow,noindex for all pages that contain comments.
Items are closed for new comments after 1 week