Posted to tcl by meissa at Tue Oct 29 19:35:32 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. exit [lindex $result 3]
  22.  
  23.  
  24. $ var="$(expect ./pw_expect.tcl -1 <p/w> ssh ... <host> <cmd> 0</dev/null)"
  25. $ echo "$var"
  26. password:
  27. <cmd output>
  28. $

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