Registrieren  •  Login 
  
 
im Forum


 News   Pastebin   Online-Tools   Kontakt 


Pastebin
Dieser Code wurde am 31.05.2013, 13:46 von killerbees19 hochgeladen.

Direktlink zu diesem Code: https://www.happytec.at/pastebin/view.php?secure=5be5e8b00d2ad43c589335183334cad8

Bash
  1. #! /usr/bin/expect
  2. ########################################################################
  3. # #
  4. # Netgear ProSafe GS108Tv2 (GS108T-200) Backup Script #
  5. # by Christian Schrötter <info@killerbees19.at> #
  6. # #
  7. # Licence: CC BY-SA 3.0 AT #
  8. # Version 1.0.0 [2013-05-31] #
  9. # #
  10. # Backup images, logs and configs from your switch to a TFTP-server. #
  11. # Tested with software version 5.0.5.4 on a Netgear GS108T-200GES. #
  12. # #
  13. # Source: http://www.blog.happytec.at/index.php?mode=view&id=302 #
  14. # Licence: http://creativecommons.org/licenses/by-sa/3.0/at/deed #
  15. # #
  16. ###############################-[ USAGE ]-##############################
  17. # #
  18. # ./gs108tv2-backup.sh CLI-HOSTNAME CLI-PASSWORD TFTP-HOST TFTP-PATH #
  19. # #
  20. # ./gs108tv2-backup.sh switch.local mypassword tftp.local /backups #
  21. # ./gs108tv2-backup.sh 10.10.10.200 mypassword tftp.local /target/s1 #
  22. # #
  23. ###############################-[ TODO ]-###############################
  24. # #
  25. # + Parse file transfer results. (successfully/failed) #
  26. # + More and/or better command line options. #
  27. # #
  28. #############################-[ CHANGELOG ]-############################
  29. # #
  30. # v1.0.0 [2013-05-31] #
  31. # * Initial release. #
  32. # #
  33. ########################################################################
  34.  
  35. # Telnet timeout.
  36. set timeout 180
  37.  
  38. # Some variables.
  39. set cli_port 60000
  40. set cli_hostname [lindex $argv 0]
  41. set cli_password [lindex $argv 1]
  42. set tftp_host [lindex $argv 2]
  43. set tftp_path [lindex $argv 3]
  44.  
  45. # Date/time format for filenames.
  46. set date [exec date --utc +%Y%m%d-%H%M%S]
  47.  
  48. # Connect to CLI.
  49. spawn telnet $cli_hostname $cli_port
  50.  
  51. # Login with username "admin".
  52. expect "Applying Interface configuration, please wait ..."
  53. send "admin\n"
  54. expect "Password:"
  55. send "$cli_password\n"
  56.  
  57. # Enter into user privilege mode.
  58. expect "(Broadcom FASTPATH Switching) >"
  59. send "enable\n"
  60. expect "Password:"
  61. send "\n"
  62.  
  63. # Upload 1st Image.
  64. expect "(Broadcom FASTPATH Switching) #"
  65. send "copy image1 tftp://$tftp_host/$tftp_path/image1_$date.img\n"
  66. expect "Are you sure you want to start? (y/n) "
  67. send "y"
  68.  
  69. # Upload 2nd Image.
  70. expect "(Broadcom FASTPATH Switching) #"
  71. send "copy image2 tftp://$tftp_host/$tftp_path/image2_$date.img\n"
  72. expect "Are you sure you want to start? (y/n) "
  73. send "y"
  74.  
  75. # Upload Buffered Log.
  76. expect "(Broadcom FASTPATH Switching) #"
  77. send "copy nvram:log tftp://$tftp_host/$tftp_path/log_$date.log\n"
  78. expect "Are you sure you want to start? (y/n) "
  79. send "y"
  80.  
  81. # Upload Error Log.
  82. expect "(Broadcom FASTPATH Switching) #"
  83. send "copy nvram:errorlog tftp://$tftp_host/$tftp_path/errorlog_$date.log\n"
  84. expect "Are you sure you want to start? (y/n) "
  85. send "y"
  86.  
  87. # Upload Trap Log.
  88. expect "(Broadcom FASTPATH Switching) #"
  89. send "copy nvram:traplog tftp://$tftp_host/$tftp_path/traplog_$date.log\n"
  90. expect "Are you sure you want to start? (y/n) "
  91. send "y"
  92.  
  93. # Upload Text Configuration.
  94. expect "(Broadcom FASTPATH Switching) #"
  95. send "copy nvram:startup-config tftp://$tftp_host/$tftp_path/config_$date.cfg\n"
  96. expect "Are you sure you want to start? (y/n) "
  97. send "y"
  98.  
  99. # Logout from CLI.
  100. expect "(Broadcom FASTPATH Switching) #"
  101. send "quit\n"
  102. expect {
  103. "Would you like to save them now? (y/n) " { send "n" }
  104. "Connection closed by foreign host."
  105. }
  106.  
  107. # \n\n ;-)
  108. system "echo"
  109. system "echo"
  110.  
  111. # Bye!
  112. close
  113. exit
Dieser Code wurde in 0.0394 Sekunden mit GeSHi farblich hervorgehoben.

 

Alle Zeiten sind GMT + 1 Stunde
Aktuelles Datum und Uhrzeit: 05.12.2021, 09:49
Nach oben
Valid HTML 4.01 Transitional
Valid CSS!

netcup - Internetdienstleistungen
 
 
[ happytec.at | forum.happytec.at | blog.happytec.at | esports.happytec.at ]