Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------
- Script 1
- -----------------------------------------------------------------------
- #!/bin/bash
- # read the parameters from the file
- declare -A params
- while read line; do
- if [[ ! $line =~ ^\# && ! -z "$line" ]]; then
- name=$(echo "$line" | cut -d' ' -f1)
- values=$(echo "$line" | cut -d' ' -f2-)
- params["$name"]="$values"
- fi
- done < params.txt
- # check if the script was called with an argument
- if [ -z "$1" ]; then
- echo "Usage: $0 parameter"
- exit 1
- fi
- # check if the parameter matches one of the supported values
- if [ ! "${params[$1]+exists}" ]; then
- echo "Error: unsupported parameter value. Expected values: ${!params[@]}"
- exit 1
- fi
- # set the variables based on the parameter
- read -r swnum pnum <<< "${params[$1]}"
- ./SWreset.sh "$swnum" "$pnum"
- -----------------------------------------------------------------------
- Script 2
- -----------------------------------------------------------------------
- #!/usr/bin/expect
- set timeout 2
- set swnum [lindex $argv 0]
- set geport [lindex $argv 1]
- spawn telnet 172.18.0.$swnum
- expect "User Name: "
- send "username\r"
- expect "Password: "
- send "password"
- set timeout 1
- expect "SW2#"
- send "conf t\r"
- set timeout 1
- expect "SW2#<config>#"
- send "int ge$gepoort\r"
- set timeout 1
- expect "SW2#<config>#"
- send "shutdown\r"
- set timeout 5
- expect "SW2#<config-if>"
- set timeout 8
- send "no shutdown\r"
- set timeout 1
- send "exit\r"
- expect "SW2<config>"
- set timeout 1
- send "exit\r"
- expect "SW2#"
- set timeout 1
- send "exit\r"
- set timeout 1
- interact
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement