Category Archives: CLI

Postfix, DKIMproxy, Spamc

If you’re running any moderately busy mail server you’re probably using spamassassins spamc/spamd to check for spam because its tons more efficient than piping the mail through the spamassassin cli. Assuming that you do, and that you plan on adding DKIM proxy to the mix to verify  and sign emails you need to put things [...]

Writing your own shell in php

I’ve always wanted to write my own simple shell in php.  Call me a glutin for punishment, but it seems like something that a lot of people could use to be able to do… If your web app had a command line interface for various things… like looking up stats, or users, or suspending naughty [...]

Command line arguments in bash scripts

This is something that has always annoyed me about bash scripts… The fact that it’s difficult to run /path/to/script.sh –foo=bar -v -n 10 blah -one=’last arg’ So I decided to write up a bash function that let me easily (once the function was complete) access this type of information. And because I like sharing, here [...]

Bash Coding Convention ../

We use dirname() a lot in php to make relative paths work from multiple locations like so. The advantages are many: require dirname( dirname( __FILE__ ) ) . ‘/required-file.php’; $data = file_get_contents( dirname(__FILE__).’/data/info.dat’); But in bash we often dont do the same thing, we settle for the old standby “../”. Which is a shame because [...]

Simple TCP Daemon Example

Using some stuff I’ve covered in the past on my blog here’s a simple way to put up a daytime server (well to put any service onto a tcp port. I haven’t looked into its bi-directional capabilities yet, this was just sort of a proof-of-concept… $ apt-get install ipsvd $ wget http://blog.apokalyptik.com/files/daemonize/daemonize.c $ cc daemonize.c [...]

This deserves some link love

Andy bogged a piece of advice that I have him which I got from Barry… and if you want to know how to get the true absolute path to the real location of the current script is from inside of it (like phps realpath and __FILE__) I suggest you check it out

As Close to A Real Daemon As Bash Scripts Get

I’ve written a little something which is gaining some traction internally, and I always intended to share it with the world. So… Here. daemon-functions.sh What it does is allow you to write a bash function called “payload” like so: function payload() { while [ true ]; do checkforterm date sleep 1 done } source path/to/daemon-functions.sh [...]

building sed for osx

I work in linux a lot… not bsd. So the OSX (bsd style) implementation of sed really throws me for a loop when I go text-file-spelunking, whats worse is that my scripts using sed aren’t portable between the two OSs. A quick googling this morning landed me here: http://wiki.octave.org/wiki.pl?OctaveForMac which gives perfectly good instructions on [...]

I keep marking this as unread in google reader…

I keep marking this as unread in google reader so that Its there when I need it… which probably means I should just blog it… automating firefox via telnet

Daemonize Anything

I hacked together this little C program from this other little c program. Basically acts as an execution wrapper that lets you fork() and detach and run a command in the background with a pidfile and log file for program output. So far I havent had any problems with it… but then I’m not a [...]