9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] lstk script
@ 2023-08-14  8:50 umbraticus
  2023-08-14  9:21 ` qwx
  0 siblings, 1 reply; 3+ messages in thread
From: umbraticus @ 2023-08-14  8:50 UTC (permalink / raw)
  To: 9front

The lstk script recently committed is a handy tool.
I humbly submit the version which I have been using.
If there are multiple broken processes it prints them
in a sendable format instead of just picking most recent.

#!/bin/rc
rfork e
p = `{ps | awk '/Broken/{print $2 " "$7}'}
if(~ $#p 2){
	echo 'echo ''lstk()'' | acid' $p(1) '#' $p(2)
	echo 'lstk()' | acid $p(1)
	exit $status
}
fn list{
	while(! ~ $#* 0){
		echo 'echo ''lstk()'' | acid' $1 '#' $2
		shift; shift
	}
}
list $p


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9front] lstk script
  2023-08-14  8:50 [9front] lstk script umbraticus
@ 2023-08-14  9:21 ` qwx
  2023-08-14 15:15   ` Stanley Lieber
  0 siblings, 1 reply; 3+ messages in thread
From: qwx @ 2023-08-14  9:21 UTC (permalink / raw)
  To: 9front

On Mon Aug 14 10:48:52 +0200 2023, umbraticus@prosimetrum.com wrote:
> The lstk script recently committed is a handy tool.
> I humbly submit the version which I have been using.
> If there are multiple broken processes it prints them
> in a sendable format instead of just picking most recent.
> 
> #!/bin/rc
> rfork e
> p = `{ps | awk '/Broken/{print $2 " "$7}'}
> if(~ $#p 2){
> 	echo 'echo ''lstk()'' | acid' $p(1) '#' $p(2)
> 	echo 'lstk()' | acid $p(1)
> 	exit $status
> }
> fn list{
> 	while(! ~ $#* 0){
> 		echo 'echo ''lstk()'' | acid' $1 '#' $2
> 		shift; shift
> 	}
> }
> list $p

Thanks umbraticus and Ori, here's also a stupidly pimped out version
that either looks up the last Broken process, or matches a given
pattern (name, pid or group, etc.), or prints matching procs and
exits.  Printing all in sendable format is a better idea there though.
I suggest we pull whatever seems useful from both scripts and any
other attempts, and that we also add one or more convenience plumb
rules such as (also stolen from Ori):

type	is	text
data	matches	'[^ ]+ ([0-9]+): suicide:.*'
plumb	to	none
plumb	start	window lstk $1

Cheers,
qwx


#!/bin/rc
rfork n
print=()
if(~ $1 -p){
	print=1
	shift
}
if(~ $#* 0)
	p=Broken
if not{
	p=$1
	shift
}
ps -a | grep $p | grep -v 'grep '^$p
p=`{ps | awk -v 'P='^$p '$7 == P || $2 == P || $6 == P{ p=$2 } END{ print p }'}
if(~ $#p 0){
	echo no proc $p >[1=2]
	exit noproctohand
}
echo scroll >/mnt/wsys/wctl
if(! ~ $#print 0){
	echo lstk'()' | acid -lthread -lpool $p
	echo acid -lthread -lpool $* $p
}
if not{
	{echo lstk'()'; cat} | acid -q -lthread -lpool $* $p
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9front] lstk script
  2023-08-14  9:21 ` qwx
@ 2023-08-14 15:15   ` Stanley Lieber
  0 siblings, 0 replies; 3+ messages in thread
From: Stanley Lieber @ 2023-08-14 15:15 UTC (permalink / raw)
  To: 9front

On August 14, 2023 5:21:07 AM EDT, qwx@sciops.net wrote:
>On Mon Aug 14 10:48:52 +0200 2023, umbraticus@prosimetrum.com wrote:
>> The lstk script recently committed is a handy tool.
>> I humbly submit the version which I have been using.
>> If there are multiple broken processes it prints them
>> in a sendable format instead of just picking most recent.
>> 
>> #!/bin/rc
>> rfork e
>> p = `{ps | awk '/Broken/{print $2 " "$7}'}
>> if(~ $#p 2){
>> 	echo 'echo ''lstk()'' | acid' $p(1) '#' $p(2)
>> 	echo 'lstk()' | acid $p(1)
>> 	exit $status
>> }
>> fn list{
>> 	while(! ~ $#* 0){
>> 		echo 'echo ''lstk()'' | acid' $1 '#' $2
>> 		shift; shift
>> 	}
>> }
>> list $p
>
>Thanks umbraticus and Ori, here's also a stupidly pimped out version
>that either looks up the last Broken process, or matches a given
>pattern (name, pid or group, etc.), or prints matching procs and
>exits.  Printing all in sendable format is a better idea there though.
>I suggest we pull whatever seems useful from both scripts and any
>other attempts, and that we also add one or more convenience plumb
>rules such as (also stolen from Ori):
>
>type	is	text
>data	matches	'[^ ]+ ([0-9]+): suicide:.*'
>plumb	to	none
>plumb	start	window lstk $1
>
>Cheers,
>qwx
>
>
>#!/bin/rc
>rfork n
>print=()
>if(~ $1 -p){
>	print=1
>	shift
>}
>if(~ $#* 0)
>	p=Broken
>if not{
>	p=$1
>	shift
>}
>ps -a | grep $p | grep -v 'grep '^$p
>p=`{ps | awk -v 'P='^$p '$7 == P || $2 == P || $6 == P{ p=$2 } END{ print p }'}
>if(~ $#p 0){
>	echo no proc $p >[1=2]
>	exit noproctohand
>}
>echo scroll >/mnt/wsys/wctl
>if(! ~ $#print 0){
>	echo lstk'()' | acid -lthread -lpool $p
>	echo acid -lthread -lpool $* $p
>}
>if not{
>	{echo lstk'()'; cat} | acid -q -lthread -lpool $* $p
>}
>

printing commands to pipe or send is very good.

sl

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-14 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14  8:50 [9front] lstk script umbraticus
2023-08-14  9:21 ` qwx
2023-08-14 15:15   ` Stanley Lieber

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).