[ale] Shell Scripting question
Geoffrey
esoteric at 3times25.net
Wed Aug 6 13:53:42 EDT 2003
nick travis wrote:
> Here's the exact line in the file, I want to pull out the file name from
> it.
> VIOLATION : PAM service rlogin (/etc/pam.d/rlogin) does not have module
> pam_shells.so for module type auth.
> ...ACTION : Add module pam_shells.so for module type auth to PAM
> service rlogin (/etc/pam.d/rlogin).
> Example: auth required /lib/security/pam_shells.so
>
> there will be several violations like this in the file, but the file
> name will start at a different location each time. since the violation
> will be in a different file.
Well, that message contains three different references to file names,
but you can get to all of them with the right tool. If for example you
want the name that's contained between the parans, you can use awk:
awk -F '[()]' '{print $2}' intputfile
The above will retreive the first occurance of /etc/pam.d/rlogin.
Basically you're telling awk that there are two field separators and
they are the parans. Therefore, the file name would be the second field.
Same solution would apply for the second /etc/pamd./rlogin entry, you'd
just have to adjust the '$2' appropriately.
The last file reference (/lib/security/pam_shells.so) can be had by the
previous posted solution:
awk '{print $NF}' inputfile
NF in awk is the number of fields, therefore $NF is the last field value.
--
Until later: Geoffrey esoteric at 3times25.net
The latest, most widespread virus? Microsoft end user agreement.
Think about it...
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list