J'ai écrit un script attendu Cisco. Une fois la connexion ssh, je veux détecter la sortie d'erreur Cisco lors de l'envoi d'une ligne de commande à partir d'un fichier, par exemple:Erreur dans le script Cisco Expect
SPAIN#sow crypto isakmp sa
^
% Invalid input detected at '^' marker.
Je veux attraper « % invalide », dans ma boucle et arrêter le programm.
foreach line $data {
expect "*#"
send "$line\r"
expect {
"% Invalid*" { send_user "\n Command [ $line ] Failed. \n"; exit 252 }
}
Je reçois ces erreurs dans la sortie:
SPAIN>enable
Password:
SPAIN#sow crypto isakmp sa
^
% Invalid input detected at '^' marker.
SPAIN#invalid command name "sow crypto isakmp sa"
while executing
"$line "
invoked from within
"expect {
"% Invalid*" { send_user "\n Command [ $line ] Failed. \n"; exit 252}
}"
("foreach" body line 4)
invoked from within
"foreach line $data {
expect "*#"
send "$line\r"
expect {
"% Invalid*" { send_user "\n Command [ $line ] Failed. \n"; exit 252}
}
}"
grâce
Merci pour l'édition @DonalFellows. – Will