Bonjour,

J'ai un code qui récupère un fichier log mais je voudrais pouvoir lire les x dernières ligne de ce fichier contenant une certaine chaîne

Voilà mon code

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
Set FSO = CreateObject("Scripting.FileSystemObject")
alert_log = ""
 
    Set oFold = FSO.GetFolder(REP)
    Resultat = ""
	Hor= "01/01/1970 00:00:37"
    For Each oFile In oFold.Files
        If LCase(Left(oFile.Name, 6))  = "alert_" And LCase(Right(oFile.Name, 4)) = ".log" Then 'récupération des fichier alert_*.log
          Resultat = oFile.Path
 
		  if FSO.FileExists(resultat) then 													'récupération du dernier fichier modifié 
				Hor_next = FSO.GetFile(resultat).DateLastModified
				diff = DateDiff("s",Hor_next,Hor)
 
				if Diff < 0 then 
				Hor = Hor_next
				alert_log = oFile.Name
				alert_path = oFile.Path
				end if 
			end if 
        End If
    Next
	wscript.echo alert_log 
	wscript.echo alert_path
 
	if alert_log = "" then 
		wscript.echo "Pas de fichier alert_*.log dans le repertoire "& REP 
		wscript.quit (ST_UK)
	end if
Pour faire la recherche je voulais utiliser une commande find de windows dans ce style là

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
ERREUR_cherche = chr(34) & ERREUR & chr(34)
		Set sh  = CreateObject("WScript.Shell")
		Set cmd = sh.Exec("cmd /c find  "& ERREUR_cherche &" " &alert_path)
read_cmd=cmd.StdOut.ReadAll
wscript.echo read_cmd
ERREUR est la chaîne recherché dans le fichier alert_path est le chemin vers le fichier où l'on veut effectuer la commande find

j'ai déjà utilisé cette commande dans un autre script elle passe bien mais la elle ne veut pas passer et impossible de trouver pourquoi quelqu'un saurait pourquoi?

Merci d'avance

Galène