From: Hades Subject: Log/Syslog Grep My fixes: (1) Code will now correctly compile. A variable definition or two was missing. (2) Using PERL, the output will now appear correctly on basic telnet clients, whereas its predecessor might have given you a newline and not a carriage return. Notes: To use this snippet, you must have perl as well as the egrep command available on your server/shell. If you wish, you can comment out the line using perl and the system(buf) command after it, but you will not get the fix for basic telnet output. If you for some reason do not have "egrep" on your shell, replace instances of "egrep" with "grep -E"... it's the same thing. -------------------------------------------------------------------- Original snippet by Katzlberger Thomas Note from KT: "Well here is a little, tiny argument against windows: Please replace/remove the C++ stuff yourself." -------------------------------------------------------------------- *** in act.wizard.c: *** ACMD(do_playerlog); // somewhere near the top, with the other ACMD defs ACMD(do_playerlog) { // put this anywhere ya like =) FILE* f; char *buf = get_buffer(MAX_STRING_LENGTH); if (!*argument) { send_to_char("Search/grep the system logs for what?\r\n",ch); return; } sprintf(buf,"egrep '%s' ../syslog > playercheck ; egrep '%s' ../log/* >> playercheck", argument, argument); system(buf); sprintf(buf,"perl -pi -X -e 's/\n/\r\r\n/' playercheck"); system(buf); f = fopen("playercheck","r"); fread(buf, MAX_STRING_LENGTH-5,1,f); buf[MAX(0,ftell(f))]=0; fclose(f); ch->Send("\r\n\n*** Log grep of \"%s\"\r\n\n",argument); page_string(ch->desc, buf, 1); release_buffer(buf); } *** in interpreter.c: *** ACMD(do_playerlog); // with your other ACMD defs /* Group the following with your other staff commands */ { "grep", "grep", POS_DEAD, do_playerlog, STAFF_CMD, LVL_IMMORT, 0 }, *** That's it! Execute "grep " from your MUD after compiling. Final note... I introduced this code into LexiMUD. I don't think I made any major changes that will affect it compiling in stock CircleMUD.