29. september 2008 - 12:08Der er
7 kommentarer og 2 løsninger
Data udtræk fra text-fil
Hej,
Jeg sidder og prøver at hive data ud fra en text fil hvorefter visse data skal sorteres.
I for udtrækket her.
"" Found 1 IBM ServeRAID controller(s). Read configuration has been initiated for controller 1... ---------------------------------------------------------------------- Physical device information ---------------------------------------------------------------------- Channel #1: Initiator at SCSI ID 7 Channel #2: Initiator at SCSI ID 7 Target on SCSI ID 0 Device is a Hard disk SCSI ID : 0 PFA (Yes/No) : No State : Online (ONL) Size (in MB)/(in sectors): 140013/286747728 Device ID : IBM-ESXSVPR146C3S410JAYSAJKK FRU part number : 39R7318 Target on SCSI ID 1 Device is a Hard disk SCSI ID : 1 PFA (Yes/No) : No State : Online (ONL) Size (in MB)/(in sectors): 140013/286747728 Device ID : IBM-ESXSVPR146C3S410JAYP8UJK FRU part number : 39R7318 Target on SCSI ID 2 Device is a Hard disk SCSI ID : 2 PFA (Yes/No) : No State : Ready (RDY) Size (in MB)/(in sectors): 140013/286747728 Device ID : IBM-ESXSST314685B86E3KN2TMFA FRU part number : 39R7318 Target on SCSI ID 3 Device is a Hard disk SCSI ID : 3 PFA (Yes/No) : No State : Ready (RDY) Size (in MB)/(in sectors): 140013/286747728 Device ID : IBM-ESXSVPR146C3S410JDWND2HK FRU part number : 39R7318 Target on SCSI ID 4 Device is a Hard disk SCSI ID : 4 PFA (Yes/No) : No State : Ready (RDY) Size (in MB)/(in sectors): 140013/286747728 Device ID : IBM-ESXSVPR146C3S410JDWNDTUK FRU part number : 39R7318 Target on SCSI ID 8 Device is a Processor device SCSI ID : 8 PFA (Yes/No) : No State : Standby (SBY) Size (in MB)/(in sectors): 0/0 Device ID : IBM 40K6480a1 000 Command completed successfully.
""
Hvordan for jeg hivet "State" udfra de forskellige diske? Evt over i en anden text fil.
Teknologi, AI og forretning er i centrum på Computerworlds Cloud og AI Festival i København d. 18. og 19. september. Se hele programmet for den store konference om strategisk brug af Cloud og AI på: www.cloud-festival.dk
Dim Drev As String, State As String, Linje As String Open "C:\data\drev.txt" For Input As #1' ret til din sti Do Line Input #1, Linje If InStr(Linje, "Target") > 0 Then Drev = Trim(Linje) End If If InStr(Linje, "State") > 0 Then State = Split(Linje, ":")(1) Debug.Print Drev & " " & State ' her er værdierne Drev = "" State = "" End If Loop Until EOF(1) Close
Dim Drev As String, State As String, Linje As String Open "C:\data\drev.txt" For Input As #1 Do Line Input #1, Linje If InStr(Linje, "Target") > 0 Then Drev = Trim(Linje) End If If InStr(Linje, "State") > 0 Then State = Linje Debug.Print Drev & " = " & Replace(Replace(State, " ", ""), ":", ": ") Drev = "" State = "" End If Loop Until EOF(1) Close
'text fil der skal søges strStatus = "C:\Tools\drev\drev.txt" 'dir hvor fil skal oprettes strDir = "C:\tools\drev\" 'filnavn strFile = "\state.txt"
'Script Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\Tools\drev\drev.txt", 1) Set NewTxt = objFSO.CreateTextFile(strDir & strFile) Do While Not objFile.AtEndOfStream line = objFile.readline If InStr(line, "State") Then NewTxt.writeline(line) End If Loop NewTxt.close
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.