Archive for June, 2007

C Reference (Glibc info)

I already knew that the linux man pages contain documentation for a lot of the C-functions.

But I just found the info pages for glibc and using yelp (gnome help), entering

yelp file:///usr/share/info/libc.info.bz2

gives the C reference manual I always wanted!
Awesome.

No Comments

Spam

For not getting confused with my emails, I use filters obviously.
For blocking Spam I use spamassassin. http://wiki.apache.org/spamassassin/
Both are integrated really nice in KMail, my favorite mail application.

Spamassessin is nice ’cause it’s actually software meant for mail servers. Thus I think the bayes and other stuff is quite good. Coolest thing is, I can also fine tune it:

The spam rating is based on scores given for the different tests run on the incoming email. As a user, you can create new test and set the scores for existant tests. If the sum hits a maximum (5 for me), it is flagged as spam. Cool feature in Kmail: You can see the spaminess (Spam score given by spamassessin)
spaminess

My .spamassassin/user_prefs:


score DATE_IN_FUTURE_12_24      5
score HTML_MESSAGE              3.3
score MIME_HTML_ONLY            5
score MULTIPART_ALT_NON_TEXT    3
score GAPPY_SUBJECT             5
score FROM_EXCESS_BASE64        3
score FROM_HAS_ULINE_NUMS       3
score UPPERCASE_25_50           3
score UPPERCASE_50_75           4
score SUBJ_ALL_CAPS             2
body EVIL_WORDS         /(software|petroleum|casino|kurs|profit|symbol)/i
score EVIL_WORDS                2
describe EVIL_WORDS     evil_words
body EVIL_WORDS2        /(price|oil|bonus|prognose|borse|preis)/i
score EVIL_WORDS2               2
describe EVIL_WORDS2    evil_words2
body DOLLAR_SIGN        /[\$]/
score DOLLAR_SIGN       3
body PERCENT_SIGN       /[\%]/
score PERCENT_SIGN      3

The 25_50 stands always for percent.

No Comments

Spam: New Spam technique: PDF

Hi!
I just received my first Spam mail containing a PDF. It was containing just the usual image-spam, but still, this is the first time I saw that.

Also noticable was that the User-Agent is set to: “Thunderbird 1.5.0.12 (Windows/20070509)”.

EDIT: Just found the link: http://www.heise-security.co.uk/news/91523

No Comments

HP-UX/Bash: Getting comfortable in your shell

Introduction: I’m talking about the weird things after opening a shell on stud4

stud4 has a ugly configuration. If you connect, you get a minimal shell. the locale is set wrong, so you see the following all the time:

 Warning! One or more of your selected locales are not available.
Please invoke the commands "locale" and "locale -a" to verify your
selections and the available locales.
Continuing processing using the "C" locale.

Also, vi is no fun, and vim doesn’t accept the extended keyboard (delete, end).

Here I want to provide some info how you can improve your comfort.

1: start bash. Way better than the default shell.

bash

2: set your locale (language and localization). This is also in which language the error messages for example are.

export LC_ALL="en_US.utf8"
#export LC_ALL="de_DE.utf8"

For example:

[e0123456@stud4:~]$ export LC_ALL="en_US.utf8"
[e0123456@stud4:~]$ man
Usage: man [-M path] [-T macro-package] [ section ] name ...
or: man -k keyword ...
or: man -f file ...
[e0123456@stud4:~]$ export LC_ALL="de_DE.utf8"
[e0123456@stud4:~]$ man
Syntax: man [-M Pfad] [-T Makro-Paket] [ Sektion ] Befehlsname ...
oder: man -k Schlüsselwort ...
oder: man -f Datei ...
[e0123456@stud4:~]$

3: allow backspace

stty erase "^?"

4: get a informative prompt (second is with color)

PS1="[\u@\h \W]\\$ "
PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"

Example:

bash-2.04$ PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"
[e0123456@stud4:~]$

List of colors and manual

If you want that in your startup, write the following into your .bashrc

#!/bin/bash
export LC_ALL="en_US.utf8"
#export LC_ALL="de_DE.utf8"
stty erase "^?"
PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"

Now you may wonder, how can I write that easily in the freaking file?

pico .bashrc

To set pico, vim, xemacs or whatever your default editor (so "crontab -e" and other commands call it), use:

export EDITOR=pico

Another funny thing is XForwarding. Try this:

ssh e0123456@stud4.tuwien.ac.at -X
bash
xemacs

Ta-daa! A fat graphical editor. Of course only if you use X.
Also funny commands you can play with: xload, xbiff++, xclock, etc.

Really useful on the stud4 server is the script quotax:

[e0123456@stud4:~]$ quotax
Disk space limits on stud4:
---------------------------
Total disk space in home directory:   200 MB
Minimal free space for mail delivery:  10 MB
Maximal capacity of inbox folder:      50 MB
Disk usage summary for user e0123456:
-------------------------------------
Used disk space in home directory:  186.0 MB [93.0 %]
Free disk space in home directory:   13.9 MB [ 7.0 %]
Number of messages in inbox folder:  213
Size of inbox folder:                 2.0 MB [ 4.0 %]
Free space for incoming messages:     3.9 MB
WARNING: Remaining disk space in home directory is very low.
-------> There is not much space left for files and incoming mails.

At the end, some useful bash and vim tips for these crippled terminals:

bash:
Ctrl-A: begin of line
Ctrl-E: end of line
Ctrl-W: delete last word
vim: (watch out if you are in edit or command mode)
:dl      Delete letter
:dw    Delete word
:dd     Delete line
:wq    Write & quit
:q!      Quit without writing or anything

It is always worthy reading the according manuals (probably not on HP-UX, but on a linux machine or man-pages on the internet).

That’s it. Try things, don’t break things, and have fun.

1 Comment

Mail/Jabber/Bash/Perl: New mail notifications via jabber

Based on an earlier post, the following is a solution to get jabber notifications for new mails.
We do this using a cronjob, but don’t worry, system administrator, it does take minimal resources.

This is dedicated to users of stud3/stud4, but will work on any server you have ssh access to.
jabber-mail-notifications

HOWTO:
1: Get the sources here and extract them. jbiff.tar (gz, 152 KB) (tar.gz archive)
There is a perl script (jabbersend.pl) with the needed modules for sending jabber messages.
Also there is a bash script (jbiff.sh) that checks if the inbox changed and calls the perl script accordingly.
Modify the line

"perl jabbersend.pl jabber.ccc.de username="J13R" password="mybottybot"
to="buchner.johannes@amessage.at" "body=$a | $b | $c"

to your needs. You probably don’t want me to receive your mails notifications. I don’t mind if you use my bot (J13R) as sender, otherwise just enter your jabber account details there.

2: Copy them to a folder in your home directory on the server. ~/test for example.
You can should test the functionality by calling “bash jbiff.sh”. It will create a .oldstatus file to not send the same notification twice.

3: add it to your crontab


export EDITOR="pico" # You probably don't want to use vi on a HP machine
crontab -e # edit the crontab and add the following line:
* * * * * cd test/; bash jbiff.sh

Watch out: Failing cronjobs will send you a error report by mail which could create a infinite loop. You can clear/remove your crontab with “crontab -r”.

Also, this script only detects that something changed and will output the last message in your mailbox, so don’t wonder if you move/delete messages.

Wanted features: I would like the messages to contain newlines (couldn’t find how to do that).

No Comments

Buchner’s Law: 80/20

In a forum/board 20 percent do troll posts. If you kick them out and stick to the 80 percent, 20 percent of them will do troll post.

No Comments

Studivz: Weg he!

weg_he
Was kann man an Studivz besser machen? Oder wo soll man anfangen?

studivz.user (js, 1 KB)
Dieses Greasemonkey-Skript (Greasemonkey vorher in Firefox installieren) ersetzt den öden Text “Log out” durch ein freundliches, flüchtendes, SIW-like “Weg he!”.

Außerdem versucht es ein bisschen Werbung zu entfernen, aber da is Adblock wohl besser.

No Comments

Linux: Encrypted WLAN

Encrypted WLAN that works for Windows and isn’t as bad as WEP: I chose WPA-PSK with TKIP.

Due to some struggle, I will post my config and setup here. I have a bcm43xx device.
First /etc/wpa_supplicant/wpa_supplicant.conf:


ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
eapol_version=1
ap_scan=1
fast_reauth=1
network={
scan_ssid=1
ssid="yourssid"
psk="yourpsk"
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
}

Bringing it up:


rmmod bcm43xx
modprobe bcm43xx
ifconfig eth1 up
iwlist eth1 scan
# there should be your net in the list, otherwise start again
iwconfig eth1 essid yourssid
killall dhclient
wpa_supplicant -Dwext -ieth1 -c/etc/wpa_supplicant/wpa_supplicant.conf

If it says something containing “success”, go on with dhclient eth1.
But it seems to be quite random sometimes: It says the key is incorrect, and the authentification is tried again in a loop.
Then I just kill it and start the list over and on the third try or something it works.

No Comments

Live Ping graph

The first snippet makes ping queries and saves the response time to pingstat.txt.


ping www.google.com |
grep --line-buffered -Eo "time=[0-9\.]+ ms" |
sed -u 's/time=\([0-9\.]*\) ms/\1/g' |
while read line; do echo $(date +%s)" $line"; done >> pingstat.txt

The second takes the last 200 from them and displays them in a graph (gnuplot).


while true; do
tail -n200 <pingstat.txt >pingstat1.txt;
echo 'plot [] [0:1000] "pingstat1.txt" with lines notitle';
sleep 1;
done } |
gnuplot

No Comments

LaTeX: Beamer Theme switcher

LaTeX + beamer package … means cool presentations.

But how to select a theme and a color theme? Which are there anyway?

The first script takes you through a tour how your presentation will look like for each theme.
The second does quite the same thing for the color schemes.

#!/bin/sh
name="switchtheme"
THEMEFILEDIR="/usr/share/texmf/tex/latex/beamer/"
INFILE="presentation.tex"
TMPINFILE="$name.tex"
TMPOUTFILE="$name.pdf"
MAKECMD="pdflatex $TMPINFILE"
DISPLAYCMD="evince $TMPOUTFILE"
THEMELIST=$*
if [ "$THEMELIST" == "" ]; then
THEMELIST=$(ls $THEMEFILEDIR |
grep 'beamertheme[A-Z]' | sed 's/beamertheme\([A-Z].*\)\.sty/\1/')
fi
for theme in $THEMELIST; do
echo $theme
cat $INFILE | sed 's/\\usetheme{[^}]*}/\\usetheme{'$theme'}/g' |
sed 's/\\title{\([^}]*\)}/\\title{\1 - '$theme'}/g' |
cat > $TMPINFILE
$MAKECMD
$DISPLAYCMD
done
rm $TMPOUTFILE $TMPINFILE $name.{out,aux,log,nav,snm,toc}

#!/bin/sh
name="switchcolor"
THEMEFILEDIR="/usr/share/texmf/tex/latex/beamer/"
INFILE="presentation.tex"
TMPINFILE="$name.tex"
TMPOUTFILE="$name.pdf"
MAKECMD="pdflatex $TMPINFILE"
DISPLAYCMD="evince $TMPOUTFILE"
THEMELIST=$*
if [ "$THEMELIST" == "" ]; then
THEMELIST=$(ls $THEMEFILEDIR |
grep 'beamercolortheme' | sed 's/beamercolortheme\(.*\)\.sty/\1/')
fi
for theme in $THEMELIST; do
echo $theme
cat $INFILE | sed 's/\\usecolortheme{[^}]*}/\\usecolortheme{'$theme'}/g' |
sed 's/\\title{\([^}]*\)}/\\title{\1 - '$theme'}/g' |
cat > $TMPINFILE
$MAKECMD
$DISPLAYCMD
done
rm $TMPOUTFILE $TMPINFILE $name.{out,aux,log,nav,snm,toc}

Start it where your tex file lives (plus change the INFILE variable). Your .tex file has to have \usetheme{something} as this will be replaced (not in your file, but a temporary).
You can also give it themes names as parameter, and it will show you only these.

,

No Comments