Kevin,
That's *very close* - the one thing I need to happen though is for the message to end up on a single line... I'm not sure how to make that happen.
*shrug*
This is my output:
-------------------------------------------------
message = The process count monitor threshold has...
Thanks, but the text string will change - sorry if I was to general but I have multiple records I'm going to be running this through and all I need to focus on is the text between the quotes...
Thanks though!
...my $description = '';
if ($record =~ /^\s+DESCRIPTION\n\s+"(.*?)"$/m) {
$description = $1;
}
-------------------------------------------------------------------------------------
That works fine as long as the description is a single line – it captures nothing if...
...this is what I ended up using:
------------------------------------
my $description = '';
if ($record =~ /^\s+DESCRIPTION\n\s+"(.*?)"$/ms) {
$description = $1;
$description =~ s/\n/ /g; # Strip any returns.
$description =~ s/\s+/ /g; #...
Actually.. I just noticed it isn't removing the returns, it is, but it's leaving gaps in between - this was copied from the output:
--------------------------------------------------------
message = This trap signifies that the SonicWALL appliance is re-initializing itself such...
...Right now this is what that line looks like:
---------------------------------------------------------
if ($record =~ /^\s+DESCRIPTION\n\s+"(.*?)"$/m) {
---------------------------------------------------------
So I should change it to the following...
...script:
-----------------------------------------------------------
my $description = '';
if ($record =~ /^\s+DESCRIPTION\n\s+"(.*?)"$/m) {
$description = $1;
} else {
print OUTFILE "Error: Description not found in record - $record";
}...
Hello!
I have a script that needs some tweaking.
Right now, I have the script grabbing a number of different lines from one file and inserting them into another.
Now what I need is to be able to grab ONLY the last digits and insert them into my file.
Here is an example of what I need to...
Thanks Miller, but that script isn't outputting anything for me... I'm getting the following error via command:
I've gone through the script and I'm not sure what the issue is... any idea?
Thanks!
------------------------------------------------------------
C:\Test>perfect.pl
syntax error at...
...if (/^(\w+)\s+(?:NOTIFICATION|TRAP)-TYPE/) {
my $object = $1;
# Get Entire Record.
my $record = $_;
until (/^\s*$/ || eof(INFILE)) {
$record .= $_ = <INFILE>;
}
# Parse for Data
my $variables = '';
if ($record =~...
OK....
My output file is MUCH more different than the original now.
Original Output:
------------------------------------------------------------
<profiles> overwrite
<.1.3.6.1.4.1.2636>
name = Nortel Contivity TrapsV1
active = yes
<netscreenTrapHw>
trap_type = 6...
So it should look like this?
I'm receiving numerous errors...
**************************************************************
use strict;
my $infile = 'traps.mib'; # 'c:\Test\TRAPS.mib';
open(INFILE, "$infile") or die "Can't open $infile: $!";
open(OUTFILE, "c:\test\snmp.cfx") or die "can't...
...I'm still not sure how to make it so it automatically outputs the file to an SNMP.CFX filed...
Right now I run the script from command like this:
*****************************
script.pl > SNMP.CFX
*****************************
How do I make it do that within the script?
Even better...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.