Posted to tcl by miessa at Tue Oct 29 19:21:09 GMT 2024view raw

  1. #!/usr/bin/expect
  2. set cmd [lrange $argv 2 end]
  3. set timeout [lindex $argv 0]
  4. set password [index $argv 1]
  5. set timeout $timeout
  6. eval spawn -noecho $cmd
  7. expect {
  8. -nocase -re "^.*password.*: " {
  9. send "$password\r"
  10. exp_continue
  11. }
  12. timeout { exit 1 }
  13. eof
  14. }
  15. catch wait result
  16. exit [lindex $result 3]
  17. $ var="$(expect ./pw_expect.tcl -1 <p/w> ssh ... <host> <cmd> 0</dev/null)"
  18. $ echo "$var"
  19. password:
  20. <cmd output>
  21. $

AltStyle によって変換されたページ (->オリジナル) /