Guest User

Untitled

a guest
Apr 16th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/usr/bin/expect -f
  2.  
  3. set remote_server [ lindex $argv 0]
  4. set login [ lindex $argv 1]
  5. set password [ lindex $argv 2]
  6.  
  7.  
  8. log_user 0 # Отключаем вывод на экран.
  9. spawn telnet $remote_server
  10. expect "UserName:" {send "$login\r"}
  11. expect "PassWord:" {send "$password\r"}
  12.  
  13. log_user 1 # Нам необходим результат поэтому активируем вывод
  14.  
  15.  
  16. set commandtxt [ open "command.txt" r]
  17. foreach uline [split [ read $commandtxt] "\n" ] {
  18.  
  19. expect "*#" {send "$uline\r"}
  20.  
  21. for {} 1 {} {
  22. expect {
  23. -timeout 5
  24. "*Next Page*" { send "n" }
  25. "More:*space*" { send " " }
  26. "*#" exit 0
  27. }
  28. }
  29.  
  30.  
  31.  
  32. }
  33.  
  34.  
  35. close $commandtxt
  36.  
  37. send "logout\r\n"
  38. log_user 0
Add Comment
Please, Sign In to add comment