PDA

View Full Version : Site UGrep Script


Yil
08-09-2011, 10:54 PM
UGrep.itcl v1.0
---------------
Extract matching fields out of userfiles

Usage:
site UGrep [ "-nozeros" ] { <fieldName> | "*" } [<regexp>]
"-nozeros" - Hide fields whose value is "0".
<fieldName> - Search particular user field only
"*" - Search against all searchable fields
<regexp> - regular expression to match against field contents, if not supplied match anything.

Output for specific field searches is sorted by the field value, and by uid for "*" searches.

Examples:
site ugrep -- usage info along with valid field list
site ugrep logonlast -- sorted list of when everybody last logged on
site ugrep tagline -- display taglines of all users
site ugrep tagline silver -- display taglines that contain the word silver
site ugrep ips silver -- display users with a hostmask that contains the word silver somewhere in at least one of them.
site ugrep -nozeros expiresat -- displays the time accounts expired or will expire at but don't show normal accounts which never expire.

Yil
08-09-2011, 11:05 PM
Please note that the list of searchable fields includes some things that aren't shown in 'site uinfo' such as logoncount and theme.

Times are in human readable form instead of the seconds since epoch they are stored in the userfile and include difference from current time is also displayed. This is really useful when viewing such things as logonlast and deletedon...

UID/GID's show number and resolved name.

This looks like it will a really handy, yet simple, tool. The next step up would be to take the userinfo export it into a SQL memory only DB and allow full SQL searches on it. That might not be a good idea because of the dependence of nxTools on a really old custom build of SQLite and I don't want dll conflicts.

Regexp is a true regular expression, you can use ^ to make it match the start of fields, \w, \s, etc. Validity of the expression is tested.

Feel free to request additional features, report bugs, or supply useful examples.

Make sure to check out 'site createdby' script here as well in case you missed it.