#!/bin/bash # Collect the current user's ssh and enable passwords echo "Rentrez votre login TACACS RR3 s'il vous plaît" echo "Normalement real.xxx01" read -s -e -r login_tacacs echo "----------------------------------------------------" echo "Rentrer votre mot de passe TACACS RR3 s'il vous plaît" read -s -e -r password_tacacs echo "----------------------------------------------------" echo "Rentrer votre login perimetre garik (RR2)" echo "Normalement prenom.nom" read -s -e -r logingarik echo "----------------------------------------------------" echo "Rentrer votre mot de passe perimete garik" read -s -e -r passwordgarik echo "----------------------------------------------------" echo -ne '\n' log_file=test-$(date +%F).log touch "$log_file"# Feed the expect script a device list & the collected passwords echo "Connecting to CVPN devices"for device in $(cat cvpn-lo0.txt); do for device_ping in $(cat cvpn-pe-ping.txt); do ./test-ospf.exp $device $login_tacacs $password_tacacs $device_ping >> $log_file; donedone echo "----------------------------------------------------" echo "Connecting to LNS devices" echo -ne '\n'for device in $(cat lns-lo0.txt); do for device_ping in $(cat lns-pe-ping.txt); do ./test-ospf.exp $device $login_tacacs $password_tacacs $device_ping >> $log_file; donedone echo "----------------------------------------------------" echo "Connecting to XR devices" echo -ne '\n'for device in $(cat xr-lo0.txt); do for device_ping in $(cat xr-pe-ping.txt); do ./test-ospf.exp $device $logingarik $passwordgarik $device_ping >> $log_file; donedone echo "----------------------------------------------------" echo "Connecting to RH devices" echo -ne '\n'for device in $(cat rh-lo0.txt); do for device_ping in $(cat rh-pe-ping.txt); do ./test-ospf.exp $device $login_tacacs $password_tacacs $device_ping >> $log_file; donedone#!/usr/bin/expect -f
exp_internal 1
# Set variables
set timeout 20
set hostname [lindex $argv 0]
set username $env(USER)
set password [lindex $argv 1]
set lo0_ping [lindex $argv 2]
# Announce which device we are working on and at what time
send_user "\n"
send_user ">>>>> Je travaille sur $hostname @ [exec date] :) <<<<<\n"
send_user "\n"
# Don't check keys
spawn ssh -o StrictHostKeyChecking=no $username\@$hostname
# Allow this script to handle ssh connection issues
expect {
timeout { send_user "\nTimeout Exceeded - Check Host\n"; exit 1 }
eof { send_user "\nSSH Connection To $hostname Failed\n"; exit 1 }
"*#" {}
"*assword:" {
send "$password\n"
}
}
# If we're not already in enable mode, get us there
expect {
default { send_user "\nEnable Mode Failed - Check Password\n"; exit 1 }
"*#" {}
}
# Enter your commands here. Examples listed below
send "ping $lo0_ping repeat 1000 source loopback0"
expect "*ms"
quit
exit--
--
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to linuxus...@googlegroups.com
To unsubscribe, send email to linuxusersgro...@googlegroups.com
For more options, visit our group at http://groups.google.com/group/linuxusersgroup
References can be found at: http://goo.gl/anqri
Please remember to abide by our list rules (http://tinyurl.com/LUG-Rules)
---
You received this message because you are subscribed to the Google Groups "Linux Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linuxusersgro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeremiah Bess