It’s now or never

Written by sdclee on May 9, 2012 Categories: Code, Software Tags: 

Simple timestamp with message proggy for use with windows batch/cmd scripts, for example:

now “starting script” >> my.log
now “ending script” >> my.log

C:\develop\now>type my.log
2012-05-09 09:02:56 : starting script
2012-05-09 09:03:06 : ending script

Grab it from github

No Comments on It’s now or never

Great bash tip from Team Tiger

Written by sdclee on February 22, 2012 Categories: bash

There’s always something new (not to say neat) to learn at the command line. A tip from Team Tiger –
“How To Discover Which Files Your Command Will Affect”
is to use CTRL-x g and CTRL-x * for example:
ls a* CTRL-x g
See the full article at Tiger Computing

No Comments on Great bash tip from Team Tiger

touch for windows

Written by sdclee on January 3, 2012 Categories: Code, Software

A little while ago I needed to use a ‘flag file’ mechanism in a windows command script, so I nipped out for a quick search for an executable version of touch for windows. Whilst I could find the program in a variety of locations, none of them appeared to have the ability to create a file if it doesn’t already exist. Now this is no great hassle but annoying to someone with my obsessions, so rather than my creating a file and then ‘touching’ it (two steps), I cracked open the excellent tiny c compiler (tcc) and spent a fair number of hours removing the rust from my c coding skills.

After the last 12 years of perl and php it certainly was an odd feeling flying the c compiler again, but great fun (whilst watching the television as a neat blaming mechanism for why it was taking so long to write). So if you find yourself  in need of the executable or the source code, pay a visit to the repository on github.

Please note that 95% of all my programming is bespoke for clients and therefore doesn’t appear in publicly accessible repos, but if there’s anything you might want by way of a short utility (bash, sed, awk, php, perl, windows cmd), add a comment to any of the postings here.

1 Comment on touch for windows

For all Archers fans

Written by sdclee on December 20, 2011 Categories: bash, Code, Software

So I have this friend we’ll call Bill (coincidentally that is actually his name). He meddles about on a narrow boat for more time than might be healthy for him (no doubt he could say the same about my sitting in front of a screen or two for hours on end). If he stays away too long on his beloved vessel (as he often does) I get a text message asking me if I have kept the previous week’s omnibus podcast of the Archers*.

Anyway, I am often behind in my own catch-up of the omnibus and usually keep a couple of past  editions on a USB stick, so I am able to send them to him using this excellent large file transfer site. That said, there is a certain amount of manual labour involved so I decided to automate the thing with a simple crontab entry set to run at 2pm each Sunday. For fun I even added a nagios monitor plugin to make sure the episodes are up to date. The episodes just sit is an listing accessible web directory.

So here’s the simple script for any newbie to bash if you want to do something vaguely equivalent.

#!/bin/bash
cd /var/www
LOG=archersfetch.log
DATE=`date +'%Y%m%d'`
URL=http://downloads.bbc.co.uk/podcasts/radio4/archersomni/archersomni
DATENOW=`date +'%Y-%m-%d %H:%M:%S'`
echo $DATENOW " Fetching archers omnibus for " ${DATE} >> $LOG
wget ${URL}_${DATE}-1120b.mp3
mv archersomni_${DATE}-1120b.mp3 archers
ls -lrt >> $LOG
nagios monitor

Nagios watching over my Archers Omnibus Podcasts

*For those in the world who don’t know what I’m talking about take a look at the website for the longest running soap on BBC radio. The podcast is available for 7 days.

 

1 Comment on For all Archers fans

Hello world!

Written by sdclee on December 18, 2011 Categories: General

Sure, it’s a traditional coder’s greeting (written in at least 441 programming languages and counting – most represented here) so it is appropriate to open this blog with something that seems at first prosaic, but turns out to have  a special energy all of its own.

So the code hole will be a place for programming snippets, software  trivia, code gems, bug stories and so on.

Watch this space …

 

No Comments on Hello world!