Category Archives: Software Development

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 [...]

It’s good for the server. It’s good for the soul.

ack (http://petdance.com/ack/), love it (thanks nikolay)

colorizing php cli scripts

It’s pretty common in most scripting languages which center around the command line (bash, perl, etc) to find information on colorizing your shell script output, mainly because those languages are tied very tightly to command line use. It can be difficult, however, to find information about adding this same nice feature to a php cli [...]

Bash Tip: Closing File Descriptors

I recently found that you can close bash file descriptors fairly easily, it goes like this: exec 0>&- # close stdin exec 1>&- # close stdout exec 2>&- # close stderr Which makes it easy to daemonize things using only bash (lets face it there are times when you JUST don’t need anything more than [...]

Throttle your Threads…

Lets say you want to run some command, such as /bin/long-command on a set of directories. And you have a lot of directories. You know it’ll take forever to complete serially, so you want to cook up a way to run these commands in parallel. You know the server CAN handle more than one command [...]