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 ~