Précédent   Forum du club des développeurs et IT Pro > Autres langages > Général Visual Basic 6 et VBScript > VBScript
VBScript Le forum d'entraide sur VBScript. Avant de poster -> La FAQ VBScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 06/12/2012, 12h15   #1
b.gaumard
Membre du Club
 
Homme
Ingénieur systèmes et réseaux
Inscription : juillet 2012
Messages : 153
Détails du profil
Informations personnelles :
Sexe : Homme

Informations professionnelles :
Activité : Ingénieur systèmes et réseaux
Secteur : Finance

Informations forums :
Inscription : juillet 2012
Messages : 153
Points : 49
Points : 49
Par défaut Creation d'un historique de pings dans un fichier texte

Bonjour,

J'ai besoin de vos lumières ...

Jai une liste de machines générés chaque jour :

Citation:
Liste_Machines.txt
1@toto
2@titi
3@tata
4@tutu
J'effectue un ping de cette liste chaque jour et je met en forme une page html qui donne :

Citation:
toto OK
titi NOK
tata NOK
tutu NOK
toto OK
titi NOK
tata NOK
tutu NOK
toto OK
titi NOK
tata NOK
tutu NOK
ci dessous le script :

Code :
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
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
Const ForReading = 1
Const ForWriting = 2 
Const ForAppending = 8
 
Set objFile = objFSO.OpenTextFile("Liste_Machines.txt", ForReading, True)
 
Set objRes = objFSO.OpenTextFile("Histo_ping.html", ForAppending,True)
 
strHTML = strHTML & "<html>" & vbCRLF
strHTML = strHTML & "<head>" & vbCRLF
strHTML = strHTML & "<title>DHCP Stats Report : " & Now & "</title>" & vbCRLF
strHTML = strHTML & "</head>" & vbCRLF
strHTML = strHTML & "<body>" & vbCRLF
strHTML = strHTML & "<table>" & vbCRLF
 
Do While objFile.AtEndOfStream <> True  
 
	Ligne = objFile.ReadLine
 
	tableau = Split(Ligne, "@")
 
	Machine = tableau(1)
 
	Set WSHShell = CreateObject("WScript.Shell")
	Set WshExec = WshShell.Exec("ping -n 1 -w 200 " & Machine)
 
	PingResult = LCase(WshExec.StdOut.ReadAll)
	wscript.echo PingResult
	strHTML = strHTML & "<tr>" & vbCRLF	
	If InStr(PingResult, "octets=") Then
		'Ping OK		
		strHTML = strHTML & "<td>" & Machine & "</td>" & "<td>OK</td>"& vbCRLF	
	Else
		'Ping NOK
		strHTML = strHTML & "<td>" & Machine & "</td>" & "<td>NOK</td>"& vbCRLF	
	End If
 
	strHTML = strHTML & "</tr>" & vbCRLF
 
Loop
 
strHTML = strHTML & "</table>" & vbCRLF
strHTML = strHTML & "</body>" & vbCRLF	
strHTML = strHTML & "</html>" & vbCRLF
 
objRes.writeLine strHTML
Comment faire pour obtenir un historique en ligne de mes pings sous cette forme :

Citation:
toto OK OK OK
titi NOK NOK NOK
tata NOK NOK NOK
tutu NOK NOK NOK
Je ne vois pas comment faire ...

Il faut passer par un fichier temp de toute facon ... pour comparer si la machine existe deja, sinon creer une autre ligne ...

Merci à vous d'avance.
b.gaumard est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 14h20   #2
omen999
Rédacteur
 
Avatar de omen999
 
Inscription : février 2006
Messages : 903
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 903
Points : 2 242
Points : 2 242
http://www.developpez.net/forums/d12...fichier-texte/
__________________
nomen omen, nemo non omen
le plus terrible lorsqu'une voiture renverse un piéton, c'est que ce sont les freins qui hurlent. (ramón)
pas de questions techniques par mp
omen999 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/12/2012, 16h49   #3
b.gaumard
Membre du Club
 
Homme
Ingénieur systèmes et réseaux
Inscription : juillet 2012
Messages : 153
Détails du profil
Informations personnelles :
Sexe : Homme

Informations professionnelles :
Activité : Ingénieur systèmes et réseaux
Secteur : Finance

Informations forums :
Inscription : juillet 2012
Messages : 153
Points : 49
Points : 49
toutes mes excuses effectivement post en double :
http://www.developpez.net/forums/d12...e/#post7016237
J'avais oublié mon post tellement j'avais abandonné Merci encore pour votre aide.
b.gaumard est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 20h05.


 
 
 
 
Partenaires

Hébergement Web