[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a few scripts...



hi folks.

i collected scripts for my private amusement.  i did them myself, no
copyright issues.  there may even be rc-scripts in my collection, because i
linked a static copy of rc(1) including integer x, : and + integer
operators to provide for a fast little scripter.

1. i use mutt(1) as mua and needed a quick mail-aliases lookup for the
   "external-query" command.  the program is configured in .muttrc like so:
   "set query_command="/l/bin/grepmalias '%s'", and has to answer with an
   arbitrary number of rows consisting of "email-address <tab> full-name
   <tab> comments":

#!/bin/es
# grepmalias, greps into mail aliases ino: Fri-02.06.00-03:53
# does still not work on:

fn aline l {
	name=(); address=()
	for (ll=$l) {
		n = <={~~ $ll \<*\>}
		!~ $#n 0 && address = ( $address $n )
		~ $#n 0 && {
			if {~ $ll *@*} {
				address = ( $address $ll )
			} {
				name = ( $name $ll )
			}
		}
	}
	return ( $address \t $name )
}

alis = `` \n {pgrep -i $1 ~/mail/.mail_aliases}

echo found $#alis matches

while {!~ $#alis 0} {
	line = <={%split $^ifs $alis(1)}
	line = $line(3 ...)
	alis = $alis(2 ...)
	outl = <={aline $line}
	echo $outl
}

2. saldo is a script called whenever my ppp dialup line terminates.  it is
   called in /etc/ppp/ppp.linkdown with:  " !bg /l/bin/saldo".

#!/bin/rc
# /usr/local/bin/saldo, Mon Feb 21 01:33:48 CET 2000, -ino:
# switched from sh() to rc() 29.02.2000-Tue-07:23 -ino:
# hier gez wiaklich loos.
# the raw connection time should be converted to minutes and logged according
# to time of day multiplied by the three appropriate rates (5/4/3 to be on the
# save/expensive side), and the charge for connecting (6feng).
# die ganze scheisssseee lehrt mir, dass sowohl expr() als auch sed() sich mit
# dem kuerzestmoeglichen match aus der affaere ziehen wollen!
# ..und ueber die order of evaluation weiss ich auch nix.
# kommen die '//' zeilen im log.connect von timing probs in pppctl?
# ..sei's wie's is:  nach sleep gips no probs no mo'
# -*- NB:  rechnen (+ addieren,x multen,: diven), geht nur mit mod. rc() -*-
# -*- NB:  in "/etc/ppp/ppp.conf werden die connex mit "rename <isp>" benannt.
# begin config section
# tarife in hundertstel feng, bitte, und incl. mehrwert
billig=250
mittel=330
teuer=722
tarif-tubfish930 = $teuer
tarif-inottub = $teuer
tarif-tubfish933 = $teuer
tarif-germcity = $mittel
tarif-germany = $teuer
tarif-germtranscity = $mittel
tarif-germtrans = $teuer
tarif-freenet = $billig
tarif-LuebeckerNachrichten = $teuer
tarif-talkline = $teuer
# end config section, give sleep a chance
sleep 2
sex=`{/usr/sbin/pppctl -ppp 3000 show modem | /usr/bin/grep 'time:'}
isp=`{/usr/sbin/pppctl -ppp 3000 show modem | /usr/bin/grep 'Name:'}
isp=$isp(2)
{{~ $#(tarif-^$isp) 0} && tarif=$teuer} || tarif=$(tarif-^$isp)
n=$sex(3)
n1=`{x $n $tarif}
n1=`{: $n1 6000}
# n1=`{+ $n1 6} die einwahlgebuehr entfaellt ab april 2000!
n=`{: $n 60}
sex=`{/bin/date +%a-%d.%m.%y-%H:%M}
>> /var/log/saldo.connect \
echo '    | ' $sex '|' $isp '|' $n min '*' $tarif '|' $n1
> /dev/speaker echo C

-- 
clemens