Rapport erreur_bash et expect
Utilisateur anonyme
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour,
je fais appelle à vous car je ne sais pas comment faire un rapport d'erreur suite a des traitements :
j'ai un script expect qui execute sur un certain nombre de commandes cisco sur des switchs. Cependant, je souhaiterais que si l'action n'a pas pu se faire jusqu'au bout quelque soit la raison, il y ait le nom du switch qui soit inséré dans un fichier erreur.txt.
voila ce que j'ai déjà fait :
#!/bin/bash
#
for switch in `cat /home/switch/iplist.txt | awk '{print $1}'`
do /home/commandes.sh $switch
if ???
then `cat /home/switch/iplist.txt | awk '{print $2}'` >>/home/erreur.txt
fi
done
Comme vous pouvez le voir, il me manque que la condition... Pourriez-vous m'aider à la déterminer s'il vous plait?
Merci d'avance.
Biscotte
je fais appelle à vous car je ne sais pas comment faire un rapport d'erreur suite a des traitements :
j'ai un script expect qui execute sur un certain nombre de commandes cisco sur des switchs. Cependant, je souhaiterais que si l'action n'a pas pu se faire jusqu'au bout quelque soit la raison, il y ait le nom du switch qui soit inséré dans un fichier erreur.txt.
voila ce que j'ai déjà fait :
#!/bin/bash
#
for switch in `cat /home/switch/iplist.txt | awk '{print $1}'`
do /home/commandes.sh $switch
if ???
then `cat /home/switch/iplist.txt | awk '{print $2}'` >>/home/erreur.txt
fi
done
Comme vous pouvez le voir, il me manque que la condition... Pourriez-vous m'aider à la déterminer s'il vous plait?
Merci d'avance.
Biscotte
A voir également:
- Rapport erreur_bash et expect
- Plan rapport de stage - Guide
- Rapport erreur windows - Guide
- Thème rapport de stage comptabilité - Forum Word
- Impossible d'afficher le rapport de tableau croisé dynamique sur un rapport existant - Forum Excel
- Acheter un rapport de stage - Forum Programmation
3 réponses
Petit récap :
le fichier de démarrage :
#!/bin/bash
#
for switch in `cat /home/switch/iplist.txt | awk '{print $1}'`
do /home/commandes.sh $switch
if ???
then `cat /home/switch/iplist.txt | awk '{print $2}'` >>/home/erreur.txt
fi
done
iplist.txt contient uniquement des adresses IP
et commandes.sh :
#!/usr/bin/expect -f
#
set switch [lindex $argv 0]
spawn ssh user@$switch
expect "#"
expect " # "
send "mdp\r"
expect " # "
send "en\r"
send "mdp2\r"
send "conf t\r"
send "no username user\r"
send "enable secret mdp3\r"
send "no aaa new-mo\r"
send "username userrw privilege 15 secret mdp4\r"
send "username userro privilege 7 secret mdp5\r"
send "aaa new-model\r"
send "aaa authentication login default group radius local\r"
send "aaa authorization console\r"
send "aaa authorization exec default group radius local\r"
send "radius-server host 192.168.0.14 auth-port 1645 acct-port 1646\r"
send "radius-server timeout 3\r"
send "radius-server directed-request\r"
send "radius-server key CiscoRadius\r"
send "radius-server vsa send authentication\r"
send "ip http authentication aaa\r"
send "ip http secure\r"
send "exit\r"
send "copy running-config startup-config\r"
send "\r"
send "\r"
send "exit\r"
expect "closed"
exit
expect eof
Merci de votre aide
le fichier de démarrage :
#!/bin/bash
#
for switch in `cat /home/switch/iplist.txt | awk '{print $1}'`
do /home/commandes.sh $switch
if ???
then `cat /home/switch/iplist.txt | awk '{print $2}'` >>/home/erreur.txt
fi
done
iplist.txt contient uniquement des adresses IP
et commandes.sh :
#!/usr/bin/expect -f
#
set switch [lindex $argv 0]
spawn ssh user@$switch
expect "#"
expect " # "
send "mdp\r"
expect " # "
send "en\r"
send "mdp2\r"
send "conf t\r"
send "no username user\r"
send "enable secret mdp3\r"
send "no aaa new-mo\r"
send "username userrw privilege 15 secret mdp4\r"
send "username userro privilege 7 secret mdp5\r"
send "aaa new-model\r"
send "aaa authentication login default group radius local\r"
send "aaa authorization console\r"
send "aaa authorization exec default group radius local\r"
send "radius-server host 192.168.0.14 auth-port 1645 acct-port 1646\r"
send "radius-server timeout 3\r"
send "radius-server directed-request\r"
send "radius-server key CiscoRadius\r"
send "radius-server vsa send authentication\r"
send "ip http authentication aaa\r"
send "ip http secure\r"
send "exit\r"
send "copy running-config startup-config\r"
send "\r"
send "\r"
send "exit\r"
expect "closed"
exit
expect eof
Merci de votre aide