S
samiam
Hello,
I know this is a trivial parse / grep job for any Perl rake worth his
salt, but does anyone have guidance on how this Perl newbie might pull
a string from one file and use this string to pull the lines in another
file out, and also pull the first line before (matching criteria) and
the first line after (matching criteria.)
I have described this in detail below.
At first I thought to use VBScript, but then I realized that Perl is
portable, doesn't necessarily have to be installed on the server, and
probably has MUCH better string processing power than VBScript. I also
considered grep, but still thought I could reuse the Perl solution in
more places.
Any input is GREATLY appreciated!
L,
S
------------
Summary: I need to find CSR numbers in FILE-A that map to registry key
entries in FILE-B, and report the pertinent surrounding info.
Detail:
I am looking to:
a.) find the lines in *.aud files with "Fail" in them
b.) Extract the Section number from the beginning of that same line.
I'll call this Section number a "CSR #"
Then use that CSR# to pull from a 2nd *.dsc file :
a.) Pull first line with CSR#
b.) Pull the first line above it with anything between two # signs,
which are section titles like this #Windows Messenger#
c.) Pull the SECOND registry key instance that is on any line below the
line with the CSR #
d.) Out put this data into a CSV file like this:
CSR#, Section Title, Registry Key
5.6.1.7.1, Windows Messenger Check, "HLM,
SOFTWARE\Policies\Microsoft\Messenger\Client,PreventRun,1,INTEGER"
Since there seem to be commas in the registry key entry, I suppose my
csv file would need to be delimited by another delimiter recognized by
Excel, which is where I ultimately want to display my data.
Below are two data samples like the data from which I will be culling.
The first sample is from a *.aud audit file.
The second is from the single DSC program file that either analyzes the
registry or can also write and change it.
Basically, I need to report the changes that our program will be making
to the registry. The audit files show the fail lines, which are lines
of a servers registry that needs to be brought into compliance.
server.aud file (audit file)
5.2.4~Local Printers Shared~NA~PASS~NA
5.8.1~FTP Server Installed~NA~PASS~NA
5.6.2~POSIX Subsystem Installed~PASS~PASS~
5.2.2~Posix Subsystem File Components - Posix.exe Not Found~NA~PASS~NA
5.2.2~Posix Subsystem File Components - Psxss.exe Not Found~NA~PASS~NA
5.2.2~Posix Subsystem File Components - Psxdll.dll Not Found~NA~PASS~NA
5.6.1.1~NetMeeting Disable Remote Desktop Sharing~FAIL~FAIL~
5.6.1.2~IE Security Zones are Local Only~FAIL~FAIL~
5.6.1.2.2~Allow User to Change IE Sec Policy~FAIL~FAIL~
5.6.1.2.3~IE Security Zones Map Editing~FAIL~FAIL~
5.6.1.2.4~IE Proxy Settings Set Per User~FAIL~FAIL~
5.6.1.2.5~IE Automatic Installs Disabled~FAIL~FAIL~
5.6.1.2.6~IE Software Update Check~FAIL~FAIL~
-----------------------------
analyze.dsc (script for analyzing/writing to registry)
# Windows Messenger #
dialog set,text1,"5.6.1.7.1 Windows Messenger Check"
dialog set,text2,"5.6.1.7.1 Do Not Allow Windows Messenger to be Run"
%%before =
@REGREAD(HLM,SOFTWARE\Policies\Microsoft\Messenger\Client,PreventRun,)
REGISTRY
WRITE,HLM,SOFTWARE\Policies\Microsoft\Messenger\Client,PreventRun,1,INTEGER
I know this is a trivial parse / grep job for any Perl rake worth his
salt, but does anyone have guidance on how this Perl newbie might pull
a string from one file and use this string to pull the lines in another
file out, and also pull the first line before (matching criteria) and
the first line after (matching criteria.)
I have described this in detail below.
At first I thought to use VBScript, but then I realized that Perl is
portable, doesn't necessarily have to be installed on the server, and
probably has MUCH better string processing power than VBScript. I also
considered grep, but still thought I could reuse the Perl solution in
more places.
Any input is GREATLY appreciated!
L,
S
------------
Summary: I need to find CSR numbers in FILE-A that map to registry key
entries in FILE-B, and report the pertinent surrounding info.
Detail:
I am looking to:
a.) find the lines in *.aud files with "Fail" in them
b.) Extract the Section number from the beginning of that same line.
I'll call this Section number a "CSR #"
Then use that CSR# to pull from a 2nd *.dsc file :
a.) Pull first line with CSR#
b.) Pull the first line above it with anything between two # signs,
which are section titles like this #Windows Messenger#
c.) Pull the SECOND registry key instance that is on any line below the
line with the CSR #
d.) Out put this data into a CSV file like this:
CSR#, Section Title, Registry Key
5.6.1.7.1, Windows Messenger Check, "HLM,
SOFTWARE\Policies\Microsoft\Messenger\Client,PreventRun,1,INTEGER"
Since there seem to be commas in the registry key entry, I suppose my
csv file would need to be delimited by another delimiter recognized by
Excel, which is where I ultimately want to display my data.
Below are two data samples like the data from which I will be culling.
The first sample is from a *.aud audit file.
The second is from the single DSC program file that either analyzes the
registry or can also write and change it.
Basically, I need to report the changes that our program will be making
to the registry. The audit files show the fail lines, which are lines
of a servers registry that needs to be brought into compliance.
server.aud file (audit file)
5.2.4~Local Printers Shared~NA~PASS~NA
5.8.1~FTP Server Installed~NA~PASS~NA
5.6.2~POSIX Subsystem Installed~PASS~PASS~
5.2.2~Posix Subsystem File Components - Posix.exe Not Found~NA~PASS~NA
5.2.2~Posix Subsystem File Components - Psxss.exe Not Found~NA~PASS~NA
5.2.2~Posix Subsystem File Components - Psxdll.dll Not Found~NA~PASS~NA
5.6.1.1~NetMeeting Disable Remote Desktop Sharing~FAIL~FAIL~
5.6.1.2~IE Security Zones are Local Only~FAIL~FAIL~
5.6.1.2.2~Allow User to Change IE Sec Policy~FAIL~FAIL~
5.6.1.2.3~IE Security Zones Map Editing~FAIL~FAIL~
5.6.1.2.4~IE Proxy Settings Set Per User~FAIL~FAIL~
5.6.1.2.5~IE Automatic Installs Disabled~FAIL~FAIL~
5.6.1.2.6~IE Software Update Check~FAIL~FAIL~
-----------------------------
analyze.dsc (script for analyzing/writing to registry)
# Windows Messenger #
dialog set,text1,"5.6.1.7.1 Windows Messenger Check"
dialog set,text2,"5.6.1.7.1 Do Not Allow Windows Messenger to be Run"
%%before =
@REGREAD(HLM,SOFTWARE\Policies\Microsoft\Messenger\Client,PreventRun,)
REGISTRY
WRITE,HLM,SOFTWARE\Policies\Microsoft\Messenger\Client,PreventRun,1,INTEGER