Label : bash

sip / digest calculation

By | | Tech | Schrijf als eerste een commentaar!

Every one in a while, I see an unexpected 403 response to a SIP client's REGISTER request. Thusfar the digest response calculation has never been wrong, but it feels good to get that check out of the way and move on to other possible causes.

For your enjoyment and mine, a Bourne-shell compatible shell script that calculates (qop-less) Digest authentication responses.

Download: hahacalc.sh (view)

$ hahacalc
Usage:   hahacalc USERNAME REALM METHOD DIGESTURI NONCE [PASSWORD] [COMPARE]
Example: hahacalc 123456789 itsp.com REGISTER sip:sip.itsp.com:6060 4f7406a80000c2f214774a48d11cc5b9e533caff7a05904c MYPASSWORD f5787ba2624dfdbcf874f46425d65b53
$ hahacalc 123456789 itsp.com REGISTER sip:sip.itsp.com ...

mocp / random / enqueue

By | | Tech | Schrijf als eerste een commentaar!

After disk failure on our company music server, I lost my enqueue-some-random-music-script.

That shan't happen again. So here, for my own enjoyment: autoenq.sh

#!/bin/sh
enqueue_app="mocp -a"
music_glob="*.mp3"
music_path="`dirname "$0"`"
list_path="$music_path/.autoenq.list"

if [ "$*" = "-c" ]; then
        # Create list of all files
        find . -type f -iname "$music_glob" > "$list_path.tmp" 2>/dev/null # no lost+found
        # Create list of all dirs that have files
        cat "$list_path.tmp" | sed -e 's/\/[^\/]*$//' | sort | uniq > "$list_path"
        exit 0
fi

args="`echo "$*" | sed -e "s/['\\\\]//g"`" # no backslashes and single quotes please
args="`echo "$args" | sed -e 's/[[:blank:]]\+/.*/g ...

executing remote command / ssh / extra escaping

By | | Tech | Schrijf als eerste een commentaar!

If you use ssh to run commands remotely, you may have run into the problem that you need an extra layer of escaping.

Let's say you have application myapp that for some reason only runs on host myserver. If you have functional ssh keys to log onto myserver it can be helpful to create a myapp wrapper on your desktop. After all, this:

$ myapp myargs

... is far more convenient than doing this:

$ ssh myserver
$ myapp myargs
$ logout

(Especially if you want to do stuff with stdin and stdout.)

The naive approach to /usr/local/bin/myapp is this:

#!/bin ...