Posted to tcl by meissa at Tue Oct 29 20:37:33 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. log_user 0
  8. expect {
  9. -nocase -re "^.*password.*: " {
  10. send "$password\r"
  11. #log_user 1
  12. exp_continue
  13. }
  14. timeout { exit 1 }
  15. eof
  16. }
  17. catch wait result
  18. #puts [string range "$expect_out(buffer)" 2 end-2]
  19. set out $expect_out(buffer)
  20. if {[string range $out 0 1] == "\r\n"} {
  21. set out [string range $out 2 end]
  22. }
  23. if {[string range $out end-1 end] == "\r\n"} {
  24. set out [string range $out 0 end-2]
  25. }
  26. puts $out
  27. exit [lindex $result 3]

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