Back up the configurations of Huawei switches using the secondary CT script (2)

Source: Internet
Author: User
Tags ssh account


The script consists of four files: tar. sh-> loop. sh-> loginfo. exp. The script logs on to each vswitch in sequence, runs the "tftp 192.168.36.44 put vrpcfg.zip" command on each vswitch, and renames the saved configuration file to the corresponding vswitch IP address. Finally, all operations are completed by packing the file name into a file on the current day. Www.2cto.com

Among them,. sh is a shell script,. exp is a reverse CT script, while the reverse CT script only completes the login and command execution function, while the shell script only processes the saved files. Do you know this? Haha
Www.2cto.com 1. loginfo. exp #! /Usr/bin/CT # note that the script is executed using CT, instead of shellset ip [lindex $ argv 0] # pass the value of $ ip from the shell script $ ip spawn ssh-v-1-c des-q-o StrictHostKeyChecking = no wang11@game-inc.com @ $ ip # enter the ssh Account Login CT "* password: "# verify CT is a command. If it matches" * password: ", continue to send" p @ ssw0rd \ r "# Switch password, \ r is the input CT "*>" # If the matching "*>" is successful, continue to run send "tftp 192.168.36.44 put vrpcfg.zip \ r" # Run the command on the switch, 192.168.36.44 is the IP address of the tftp server. "*>" # send "quit \ r "# Log out of the vswitch using CT eof # executing CT script execution ends 2. loop. sh #! /Bin/shwhile read ipdow.ct loginfo. exp $ ip # Call loginfo. exp script www.2cto.com mv/opt/tftp/vrpcfg.zip/opt/tftp/$ip.zip # rename the configuration file on tftp to the corresponding IP address done <ip.txt 3. tar. sh #! /Bin/sh loop. shcd/opt/tftptar-zcvf $ (date required policyuncm=d=.tar.gz *. zip # package all files in rm-rf/opt/tftp/* after the entire loop ends /*. zip4. ip.txt 192.168.36.11942536.2 ...... Run all the scripts above 192.168.36.254 in the same directory. [root @ localhost opt] # sh-x tar. sh
To be continued ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.