Advertisement
Guest User

Untitled

a guest
Jul 30th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | None | 0 0
  1. #!/bin/bash
  2. set -x
  3.  
  4.  
  5. USER=""
  6. PASSWD=""
  7.  
  8.  
  9. LOG="ssh_conn.log"
  10.  
  11.  
  12. HOSTS="
  13. ******
  14. ******
  15. ******
  16. ******
  17. "
  18.  
  19.  
  20. for H in $HOSTS
  21. do
  22.  
  23.  
  24. echo START SCRIPT: >> $LOG
  25. date +%x-%R >> $LOG
  26.  
  27.  
  28. COMM="
  29.  
  30.  
  31. #Время ожидание expect
  32. set timeout 1
  33.  
  34. #Соедиение ssh:
  35. spawn ssh $USER@$H
  36. expect \"*(yes/no)?*\" {send \"yes\r\"}
  37. expect \"Password:\"
  38. send \"$PASSWD\r\"
  39.  
  40.  
  41. expect \"*>\"
  42. send \"mca-dump"\r\"
  43. send \"ifconfig" \r\"
  44. send \"iostat"\r\"
  45. expect \"*>\"
  46. send \"exit\r\"
  47.  
  48. #Завершение выполнения expect:
  49. expect eof
  50. "
  51.  
  52.  
  53. expect -c "$COMM" >> $LOG
  54.  
  55.  
  56. echo ========================================================================= >> $LOG
  57.  
  58. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement