BASH: Grepping/sedding/etc out part of a file... (from one word to 'blank' line)
I have a file that lists data about a system. It has a part that can look like:
the errors I'm looking for with other errors:
or, just the errors I need to parse for:
or, if no alerts:
What I need to do is parse the file, and branch iff the error "Password Incorrect" or "Login Error" comes up. If those come up with other errors that is fine. The file doesn't always include errors (actually this is usually the case). Also, what makes this difficult for me is the line after the last alert isn't blank -- it actually contains a single space.
I have code for it, but it's getting messier and messier, and I'm sure you guys help me out with something WAY more elegant.
I want to grep out a part of a snort rule based on the SID given, but all i want as the output is the part in the quotes after the msg: An example line looks something like this:
alert tcp any any -> 127.0.0.1 any (msg:"Example Message"; classtype:Example; sid:123456;)
I would want it to... (7 Replies)
Hello,
This is my first post on the forums. So I want to start by thanking anyone who is kind enough to read this post and offer advise. I hope to be an active contributor now that I've found these forums.
I have an issue that I figure would be a good first post..
I have 2 text files... (5 Replies)
here is the line on which i want to process
`empNo` int(13) NOT NULL AUTO_INCREMENT,
it sometimes doesnt have comma at the end too
`empNo` int(13) NOT NULL AUTO_INCREMENT
i want to extract all except "AUTO_INCREMENT" not only this line i ,want the code to work on any line if it has... (5 Replies)
hi guys
in my bash script I have a file which has lines that look the following way:
dog cat "bird" red/ (blue/pink)
OR
dog cat "bird" red/ (blue/pink)
no matter what are the words of the line or how many they are I only want to keep from each line--that can look like either the... (1 Reply)
Hi,
I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this:
Name =A
xxxxxx
yyyyyy
zzzzzz
aaaaaa
bbbbbb
Value = 57
This is necessary because in a file there are written more lines which... (6 Replies)
Hi
I have the xml file as
<Head="Test" Id="3" >
<Title="mode" >
I have used the code to grep the words "Test" and "mode" as
Head=`cat file.xml | grep "Head" | awk -F "=" '{print $2}' | awk -F " " '{print $1}'`
Tilte=`cat file.xml | grep "Title" | awk -F "=" '{print... (3 Replies)
Hi All,
Hope you guys had a wonderful weekend
I have a scenario where in which I have to read a file line by line
and check for few words before redirecting to a file
I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
hello.
How to remove first word from line. The line may or may not start with blank.
NEW_PARAM1=$(magic-command " -t --protocol=TCP -P 12345-u root -h localhost ")
NEW_PARAM2=$(magic-command "-t --protocol=TCP -P 12345 -u root -h localhost ")
I want NEW_PARAM1 equal to NEW_PARAM2 equal ... (2 Replies)
Dear All,
In a CSV file, say that a given column has been extracted. In that column, information is missing (i.e. blank lines appear). I would like to replace the blank lines by the last valid line (not blank) previously read.
For example, consider the extract below:
123
234
543
111... (7 Replies)
Discussion started by: bagvian
7 Replies
LEARN ABOUT DEBIAN
glib::error
Glib::Error(3pm) User Contributed Perl Documentation Glib::Error(3pm)NAME
Glib::Error - Exception Objects based on GError
SYNOPSIS
eval {
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($filename);
$image->set_from_pixbuf ($pixbuf);
};
if ($@) {
print "$@
";
if (Glib::Error::matches ($@, 'Gtk2::Gdk::Pixbuf::Error',
'unknown-format')) {
change_format_and_try_again ();
} elsif (Glib::Error::matches ($@, 'Glib::File::Error', 'noent')) {
change_source_dir_and_try_again ();
} else {
# don't know how to handle this
die $@;
}
}
DESCRIPTION
Gtk2-Perl translates GLib's GError runtime errors into Perl exceptions, by creating exception objects based on Glib::Error. Glib::Error
overloads the stringification operator, so a Glib::Error object will act like a string if used with print() or warn(), so most code using
$@ will not even know the difference.
The point of having exception objects, however, is that the error messages in GErrors are often localized with NLS translation. Thus, it's
not good for your code to attempt to handle errors by string matching on the the error message. Glib::Error provides a way to get to the
deterministic error code.
You will typically deal with objects that inherit from Glib::Error, such as Glib::Convert::Error, Glib::File::Error,
Gtk2::Gdk::Pixbuf::Error, etc; these classes are provided by the libraries that define the error domains. However, it is possible to get a
base Glib::Error when the bindings encounter an unknown or unbound error domain. The interface used here degrades nicely in such a
situation, but in general you should submit a bug report to the binding maintainer if you get such an exception.
METHODS
scalar = Glib::Error::new ($class, $code, $message)
scalar = $class->new ($code, $message)
o $code (Glib::Enum) an enumeration value, depends on $class
o $message (string)
Create a new exception object of type $class, where $class is associated with a GError domain. $code should be a value from the
enumeration type associated with this error domain. $message can be anything you like, but should explain what happened from the point of
view of a user.
integer = $error->code
This is the numeric error code. Normally, you'll want to use "value" instead, for readability.
string = $error->domain
The error domain. You normally do not need this, as the object will be blessed into a corresponding class.
string = $error->location
The source line and file closest to the emission of the exception, in the same format that you'd get from croak() or die().
If there's non-ascii characters in the filename Perl leaves them as raw bytes, so you may have to put the string through
Glib::filename_display_name for a wide-char form.
boolean = $error->matches ($domain, $code)
o $domain (string)
o $code (scalar)
Returns true if the exception in $error matches the given $domain and $code. $domain may be a class name or domain quark (that is, the
real string used in C). $code may be an integer value or an enum nickname; the enum type depends on the value of $domain.
string = $error->message
The error message. This may be localized, as it is intended to be shown to a user.
Glib::Error::register ($package, $enum_package)
o $package (string) class name to register as a Glib::Error.
o $enum_package (string) class name of the enum type to use for this domain's error codes.
Register a new error domain. Glib::Error will be added @package::ISA for you. enum_package must be a valid Glib::Enum type, either from a
C library or registered with "Glib::Type::register_enum". After registering an error domain, you can create or throw exceptions of this
type.
scalar = Glib::Error::throw ($class, $code, $message)
scalar = $class->throw ($code, $message)
o $code (Glib::Enum) an enumeration value, depends on $class
o $message (string)
Throw an exception with a Glib::Error exception object. Equivalent to "croak (Glib::Error::new ($class, $code, $message));".
string = $error->value
The enumeration value nickname of the integer value in "$error->code", according to this error domain. This will not be available if the
error object is a base Glib::Error, because the bindings will have no idea how to get to the correct nickname.
SEE ALSO
Glib
COPYRIGHT
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Glib for a full notice.
perl v5.14.2 2012-05-24 Glib::Error(3pm)