Thread bisherige Skriptausgabe soll zusammengeführt werden
(12 answers)
Opened by choff at 2011-10-05 18:14
So bis jetzt lese ich die Daten ja aus __DATA__ ein. Jetzt möchte ich diese Daten direkt mit Befehlen in einem Skalar speichern. Also:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... my $cmd = "Befehl1"; my $cmmd = "Befehl2"; my $output = `$cmd & $cmmd`;#gleicher Inhalt wie __DATA__ # Daten einlesen und HoH befüllen while (my $row = $output) { #so hatte ich mir das gedacht, anstatt __DATA__ chomp $row; if ($row =~ m/ElementID/) { # eine Key-Zeile @keys = split(/\|/, $row); @values = (); # neue Key-Zeile, daher Values löschen } elsif ($row =~ /\|/) { # eine Value-Zeile @values = split(/\|/, $row); } else { # eine leere Zeile next; } ... Zum Test habe ich $output mal ausgeben lassen, die while schleife und den rest dabei auskommentiert. Aber so einfach funktioniert das sicher nicht :( Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #!/usr/bin/perl use strict; use warnings; my %elements; # HOH key = ElementId, value = Hashref gemergeter Datensatz # Arrays f�r die Werte in je einer Zeile my @keys; my @values; my $row; my $cmd = "Befehl1"; my $cmmd = "Befehl2"; my $output = `$cmd & $cmmd`; print $output; CreationClassName|ElementName|Name|OnTimeInMilliseconds Msvm_ComputerSystem|GWENT01|GWENT01|0 Msvm_ComputerSystem|DevManage|0454C4E6-2C92-41C1-A5FD-D9F145D798D4|1457375906 Msvm_ComputerSystem|Goliat4|0AF25718-009E-4D1A-919F-9E0DB2648AEA|1456673478 Msvm_ComputerSystem|CactiEZ|1C75D9AF-C0C3-4D10-B100-E95B7445DF22|1456833743 Msvm_ComputerSystem|Leowsuse3|1D05E39D-EB23-4E9C-BB73-390193B08C7A|889201713 Msvm_ComputerSystem|IPplan|23202E3D-9C0E-418D-9698-4C849901C087|0 Msvm_ComputerSystem|W2k-XP-W2k3|2E134AE0-39B8-43A7-8865-7D6568DD8FFA|1457529023 Msvm_ComputerSystem|Erwin2test|3DD2DE49-6AC5-4B5A-AD3C-0563C7890DFC|0 Msvm_ComputerSystem|Leowsuse|558A0B1E-19DF-48B8-AEEF-1C981109A1BC|1457424443 Msvm_ComputerSystem|Enterprise|6A07D0CA-5CB5-4A77-A385-57D0A0FF1DE9|1456702718 Msvm_ComputerSystem|Nero|6A1E7AF0-D76F-4EA8-BA2A-37C7E32454C4|1454398178 Msvm_ComputerSystem|ADMTL02|9120EA07-BC2D-4D4E-9DAB-DEA283329250|1457214075 Msvm_ComputerSystem|G5Kopie|B055A594-AEC1-4289-AC9D-0BDBFB89ED59|0 Msvm_ComputerSystem|ADMTL04|B760EB72-88B5-4EB7-AFFF-A92DDFC60AC2|1457063376 Msvm_ComputerSystem|observer|B8B57A6C-30A1-49DF-B703-0A1FB4F749D8|1457640312 Msvm_ComputerSystem|Emil|C8A53044-6D54-45BA-ADD0-8FBF58060784|1454309725 Msvm_ComputerSystem|SQELSA|D2B60270-5159-4584-B7A3-6F258CFF16A1|1457574883 Msvm_ComputerSystem|Nhand01|DAC4F1DE-0B96-4451-AA67-4C6C3CEEE4D2|1454553135 Msvm_ComputerSystem|ADMTL01|DBC49355-FF05-4DBE-9BAF-FF40AE0BE3D4|865461715 Msvm_ComputerSystem|Goliat5|E1B1B665-2390-467C-BD70-2F697A973340|938440100 Msvm_ComputerSystem|Test W2k3|F0FB37C2-199E-44DC-9751-5DFE30758305|1457547593 Msvm_ComputerSystem|Acslpz01|FAF99B6C-654D-4423-B952-91D9CAAC2807|1457307857 Msvm_ComputerSystem|ADMTL03|FF53299C-4324-4A48-812F-8C38D264A340|1457173984 CreationClassName|DeviceID|LoadPercentage|SystemCreationClassName|SystemName Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|0|Msvm_ComputerSystem|0454C4E6-2C92-41C1-A5FD-D9F145D798D4 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|0|Msvm_ComputerSystem|0AF25718-009E-4D1A-919F-9E0DB2648AEA Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|3|Msvm_ComputerSystem|1C75D9AF-C0C3-4D10-B100-E95B7445DF22 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|1|Msvm_ComputerSystem|1D05E39D-EB23-4E9C-BB73-390193B08C7A Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|0|Msvm_ComputerSystem|2E134AE0-39B8-43A7-8865-7D6568DD8FFA Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|2|Msvm_ComputerSystem|558A0B1E-19DF-48B8-AEEF-1C981109A1BC Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|1|Msvm_ComputerSystem|6A07D0CA-5CB5-4A77-A385-57D0A0FF1DE9 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|2|Msvm_ComputerSystem|6A1E7AF0-D76F-4EA8-BA2A-37C7E32454C4 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\1|1|Msvm_ComputerSystem|6A1E7AF0-D76F-4EA8-BA2A-37C7E32454C4 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|3|Msvm_ComputerSystem|9120EA07-BC2D-4D4E-9DAB-DEA283329250 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|0|Msvm_ComputerSystem|B760EB72-88B5-4EB7-AFFF-A92DDFC60AC2 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|3|Msvm_ComputerSystem|B8B57A6C-30A1-49DF-B703-0A1FB4F749D8 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|3|Msvm_ComputerSystem|C8A53044-6D54-45BA-ADD0-8FBF58060784 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|0|Msvm_ComputerSystem|D2B60270-5159-4584-B7A3-6F258CFF16A1 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|1|Msvm_ComputerSystem|DAC4F1DE-0B96-4451-AA67-4C6C3CEEE4D2 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|1|Msvm_ComputerSystem|DBC49355-FF05-4DBE-9BAF-FF40AE0BE3D4 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|96|Msvm_ComputerSystem|E1B1B665-2390-467C-BD70-2F697A973340 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\1|94|Msvm_ComputerSystem|E1B1B665-2390-467C-BD70-2F697A973340 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|0|Msvm_ComputerSystem|F0FB37C2-199E-44DC-9751-5DFE30758305 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|2|Msvm_ComputerSystem|FAF99B6C-654D-4423-B952-91D9CAAC2807 Msvm_Processor|Microsoft:b637f346-6a0e-4dec-af52-bd70cb80a21d\0|1|Msvm_ComputerSystem|FF53299C-4324-4A48-812F-8C38D264A340 Wie löse ich das nun wieder? |