Bonjour à tous,

mon script se connecte en SSH sur mes Switch, cependant si le Protocole SSH n'est pas présent sur le Switch, je souhaite passer en telnet.

problème, je ne sais pas comment faire pour lui dire si SSH Non OK alors tester Telnet.

voici mon script

Merci de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
Dim stRep_audit
Dim arrSwitchList
Dim commande1
Dim commande2
Dim commande3
Dim commande4
Dim commande5
Dim arrSwitchLines()
Dim i
Dim f
 
 
commande1 = "set logging local console enable file enable"
commande2 = "set logging default severity 5"
Commande3 = "set logging application all level 5"
Commande4 = "save config"
Commande4 = "exit"
 
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\audit\enterasys.txt", 1)
Do Until objFile.AtEndOfStream
     Redim Preserve arrSwitchLines(i)
     arrSwitchLines(i) = objFile.ReadLine
     i = i + 1
Loop
objFile.Close
For l = Ubound(arrSwitchLines) to LBound(arrSwitchLines) Step -1
    Wscript.Echo "lecture IP:" &"" &arrSwitchLines(l)
    commande()
Next
 
 
 
 
 
sub commande()
Set WshShell = WScript.CreateObject("WScript.Shell")
Wscript.Echo "connexion sur IP:" &"" &arrSwitchLines(l)
WshShell.Run "putty.exe -ssh *******@"&arrSwitchLines(l) &"-pw ********"
WScript.Sleep 2000
WshShell.AppActivate arrSwitchLines(l) &"- PuTTY"
WScript.Echo commande1
WshShell.SendKeys "set logging local console enable file enable{ENTER}"
WScript.Echo commande2
WshShell.SendKeys "set logging default severity 5{ENTER}"
WScript.Echo commande3
WshShell.SendKeys "set logging application all level 5{ENTER}"
WScript.Echo commande4
WshShell.SendKeys "save config{ENTER}"
 
WScript.Sleep 6000
WshShell.SendKeys "exit{ENTER}"
WScript.Echo commande5
 
 end sub