9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Akshat Kumar <akumar@sounine.nanosouffle.net>
To: 9fans@9fans.net
Subject: [9fans] couple of scripts - specific tasks
Date: Fri,  2 Jan 2009 02:20:22 -0800	[thread overview]
Message-ID: <430b3d514e89f59a0e03b1329074bf23@sounine.nanosouffle.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 880 bytes --]


Largely useless scripts that'll perhaps save someone a few minutes or
at least a few keystrokes -- they've been done with simplicity, not
conciseness or efficiency, in mind.  No usage info (fn) is provided.

convo/fmt is to be used with "generic" IRC logs like the one produced
by andrey's irc7 (which does not include timestamps), in order to get
some of the last lines of dialog, output in tabbed format for
legibility.
	convo/fmt me nick /tmp/log 10
gets 10 latest lines of convo between 'me' and 'nick'
	convo/fmt '#channel' '' /tmp/log 10
gets 10 latest lines of convo in #channel

chkill is a kill(1) equivalent for processes being run by, i.e., none
-- to be used by hostowner
it made restarting httpd happen in less keystrokes, and the excessive,
imitative, output is enthralling.


reminder for somethings,
and a cry for help regarding others,
ak

[-- Attachment #2: fmt --]
[-- Type: text/plain, Size: 518 bytes --]

#!/bin/rc

j=''
chan=''

fn format{
	if(~ $1 '#'*){
		if(! ~ $1 $chan)
			echo $1
		chan=$1
		shift
		output $j $* |
			awk '{print "  " $0}' |
			fmt
	}
	if not
		output $j $* | fmt
	j=$1
}

fn output{
	if(~ $1 $2){
		shift 2
		echo '  ' $*
	}
	if not{
		shift
		echo
		echo $*
	}
}

grep -e $2^'.*PRIVMSG '^$1^'.*|^PRIVMSG '^$2^' :' $3 |
tail $4 |
sed '
	s/^PRIVMSG ((#.*)?).* :/\1 ⇒ /g
	s/:(.*)!.* PRIVMSG ((#.*)?).* :/\2 \1→ /g
	s/
//g' |
while(line=`{read}) format $line

[-- Attachment #3: chkill --]
[-- Type: text/plain, Size: 167 bytes --]

#!/bin/rc

for(i){
	ps | grep $i |
		while(line=`{read}){
echo 'chmod 777 /proc/'^$line(2)^'/note &&		#'^$line(7)^'
	echo kill > /proc/'^$line(2)^'/note'
		}
}

             reply	other threads:[~2009-01-02 10:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-02 10:20 Akshat Kumar [this message]
2009-01-02 13:11 ` Russ Cox
2009-01-02 18:17   ` Akshat Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=430b3d514e89f59a0e03b1329074bf23@sounine.nanosouffle.net \
    --to=akumar@sounine.nanosouffle.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).