Author Archive for OtherMachines

How long are you prepared to spend trying to find a quick way of doing something?

In my case, well over an hour.

I had about 20 or so .htm files I needed renaming as .php and I couldn’t be bothered to change them all by hand. I have a computer, right? I know a bit of DOS, a bit of UNIX, there must be a nifty command line trick for this, right?

Well, easy enough in DOS:
ren *.htm *.php
would probably do the trick if memory serves.

What about in Mac OS X? There are shareware and freeware programs to do this, but the ones that seemed any good were crippled and I wasn’t prepared to pay $20 for this task. Some didn’t work when downloaded. So back to the command line.

‘mv’ is the rather quaint UNIXy way of renaming files, but
mv *.htm *.php
doesn’t do what you might hope.

So I hit Google. Found something fairly promising, couldn’t figure out why it didn’t work, then I read it more carefully and realised it was the C shell, and OS X uses the BASH shell by default.

Eventually after a lot of swearing at Google, I found this page which had the answer. Copied the code into TextWrangler, saved it as ‘ren’ in the file I was working on and typed
. ren ‘htm$’ ‘php’ *.htm

What a palarver… it would, of course, been far quicker to rename them all by hand. But I couldn’t bear to do that.

—-

#!/bin/sh
# we have less than 3 arguments. Print the help text:
if [ $# -lt 3 ] ; then
cat <<HELP
ren — renames a number of files using sed regular expressions

USAGE: ren ‘regexp’ ‘replacement’ files…

EXAMPLE: rename all *.HTM files in *.html:
ren ‘HTM$’ ‘html’ *.HTM

HELP
exit 0
fi
OLD=”$1″
NEW=”$2″
# The shift command removes one argument from the list of
# command line arguments.
shift
shift
# $* contains now all the files:
for file in $*; do
if [ -f "$file" ] ; then
newfile=`echo “$file” | sed “s/${OLD}/${NEW}/g”`
if [ -f "$newfile" ]; then
echo “ERROR: $newfile exists already”
else
echo “renaming $file to $newfile …”
mv “$file” “$newfile”
fi
fi
done

The Flip-side of Giles Booth

In a, frankly rare, moment of solipsism, I googled myself and discovered that there was a settler in a place called Southold in colonial New York called Giles Booth. (There was also an Obadiah Booth and a Mehitophel Booth too - I bet they were just a couple of crazy guys.)

Then the other night the good people at BBC Four showed a Play for Today called The Flip-side of Dominic Hide, which I first saw when I was precisely one third the age I am today. It made a big impression on me all those years ago, and evidently made a big impression on the composer Michael Tippett too, as he pinched the plot for one of his operas.

It’s a lovely story about a man who travels back in time to the present (1980) to collect information on London Transport. But he discovers that there was a man in London in 1980 with the same name as him - Dominic Hide - and he resolves to find him. It turns out that he fathers a child in 1980, the Dominic Hide of 1980 is in fact his son.

So as I fell asleep I wondered if I, or my descendents, be travelling back to colonial New York to trace the other Giles Booth..?

Catching the Lincolnshire Poacher

As a youth I think it’s fair to say I didn’t get out much. I used to spend Sunday mornings listening to short wave radio, mainly for short-wave pirates and English-language programmes from stations like Radio Netherlands.

But occasionally I’d hear something stranger. Weird echoing chimes or music followed by numbers read out in a mechanical voice. Some of them were quite chilling - cold female voices reciting numbers in German or English.

I now know that these were ‘numbers stations’ - almost certainly these are coded transmissions from various secret services to their agents.

Many years later I was working as London producer for NPR, and we had a man called Robin Rimbaud (a.k.a. Scanner) in for an interview - he made music incorporating recordings of numbers stations. Lots of other people have done the same, such as Stereolab, Wilco, Boards of Canada and Pere Ubu.

I’d assumed that numbers stations had died out at the end of the Cold War, but a fair bit of Googling suggests they’re still with us. It might seem odd, quaint even, in the era of the internet, SMS and PGP, to still be using numbers read out over short wave. But it makes a lot of sense - there’s no route of IP numbers to trace, no records on hard drives. All you need is an innocuous radio set (and a rather less innocuous one-time pad or code-book!).

There are some fine audio clips on the web - for example at http://home.freeuk.com/spook007/ - I remember hearing the Swedish Rhapsody’s child-like voice, and it scared the willies out of me too.

A couple of the web sites I found said that at almost any time of the day or night there are numbers stations on the air. So I dusted off my short-wave radio, and scanned the dial. Maybe I’d find the Lincolnshire Poacher (MI6, supposedly active, and hey, kinda catchy!). Maybe the strange polyphonic beauty of XPH?

No. Nothing. Not even armed with a ’schedule’ for the Lincolnshire Poacher.

I think I might possibly have heard a very brief snatch of a station believed to be Algerian called ‘Magnetic Fields’ - but then again, it might just have been a radio station playing a bit of ‘Magnetic Fields’by Jean Michelle Jarre.

The Smiths in MIDI

I gave up trying to get my Motorola C350 to work with iSync in Tiger - I thought I could do a different version of the same hack I’d done in Panther, but it just wouldn’t work. This was quite annoying, considering that Apple list the C350 as iSync compatible on their web site.

But what the hey - got me a secondhand Motorola V600. Now don’t get me wrong, I still hate Motorola phones, I still think their head of human interface design looks like this. (It’s the way that the menu buttons work when sending a message, the way that even though this is a clamshell, the buttons on the side turn the ringtone silent in your pocket…)

But this phone has Bluetooth. Hey, my new PowerBook has Bluetooth. I wonder if…

And they talk to each other beautifully! So easy to get wallpaper on and off. And, so so easy to add my own MP3 ring tones (edited in Audacity) and so easy to get free MIDI ring tones off the web.

And I discovered that Smiths songs played in MIDI format on a mobile phone invariably sound like New Order.

Sneaky QuickTime 7 full screen workaround

Boris and I were chatting in the park about Shynola’s wonderful video for Move Your Feet, and naturally when I got home I wanted to download it.

But lo! QuickTime 7.0.1 says you need to upgrade to QT Pro for �20 just to be able to view it full screen. Even if you shell out �20, it will attempt to smooth and anti-alias video when you enlarge it, which you really don’t want with a video like this. You want raw, nekkid pixels.

Anyway, I found a way of watching videos full screen (or nearly) for free.

Go to System Preferences > Universal Access.

Click Zoom on, click on Preferences and turn the zoom up to about 10x for the Shynola masterpiece. You can choose if you want smoothing or not (I don’t think QuickTime Pro even gives you the option!)

Back in QuickTime, put your cursor over the video and invoke Zoom by pressing apple-option-equals.

And don’t forget to Move Your Feet!

Simple PHP text file editor

I was looking around for some VERY simple PHP code that would allow me to edit a text file on a web server.

I came across this code, but for the life of me couldn’t get it to work. It would read the contents of the text file but never modify it.

I don’t know if it’s a PHP dialect issue, but I’ve now got it working on Apache on Mac OS 10.3 with the following tweaks:

if ($submit)
at the top of the original is now
if (($_POST['submit']) == “submit”)
This detects if the form has been submitted; if it has, it then goes on to rewrite the text file.

fwrite($fp, stripslashes($newdata));
is now
fwrite($fp, stripslashes($_POST['newdata']));

Maybe I’m missing something, but it seems logical that a form returns an array, and in order to process the form you need to access the individual elements of the array. Just writing ‘$newdata’ (rather than telling PHP it’s the ‘newdata’ bit of the submitted form) seems too simple!

Anyway, here’s my code. You’ll need a text file in the same directory called data.txt and you’ll need to change its permissions I suppose. I really must read up on Unix permissions and PHP next…

<?php

if (($_POST['submit']) == “submit”) {
$fp = fopen(”data.txt”,”w”);
fwrite($fp, stripslashes($_POST['newdata']));
fclose($fp);
}

// was stripslashes($newdata);

$fp = fopen(”data.txt”,”r”);
while (!feof($fp)) {
$data .= fgets($fp, 4096);
}
fclose($fp);

?>

<html>
<head>
<title>php form test</title>
</head>

<body>

<p>Adapted from http://www.onaje.com/php/article.php4/23
by othermachines.org

<p>The contents of a text file called data.txt is displayed in
the edit window below and you can edit it and save it by
clicking on the Submit button.

<form action=”<? print $PHP_SELF; ?>” method=”post”>
<textarea name=”newdata” rows=”10″ cols=”40″>
<?
print $data;
?>
</textarea>

<input type=”submit” name=”submit” value=”submit”>
</form>

</body>
</html>

Panther forgetting WEP password

I finally upgraded to Panther (Apple MacOS 10.3) on my 500 mHz iBook, and aside from the disappointment of not getting the funky Quantel-esque graphic show in Fast User Switching, all seemed well.

That was until I turned WEP encryption back on on my WiFi router - an Alcatel SpeedTouch 570. Now my iBook lost its WiFi settings every time it went to sleep, which was deeply tedious. Having to type in a random 128 bit hex WEP key is tedious. And frustrating, as the Internet Connect panel won’t allow you to cut and paste hex keys.

My router does not broadcast its SSID by default, which seems to be part of the problem. Panther, it appears, likes its SSIDs sent in the clear for all to see. There’s some debate about whether this is a security risk or not - apparently it’s quite easy to gather non-broadcast SSIDs and even 128-bit WEP encryption can be broken relatively easily, but I figure that some basic precautions are a good idea to deter casual snoopers.

Anyhoo, it looks like good old MacIntouch has the answer - ignore Internet Connect, ignore the Airport control icon in the menu bar - go straight to System Preferences > Network, highlight ‘Airport’ and press the ‘Configure’ button. Under ‘By default join…’ enter your SSID and password - as I was using 128bit hex, I typed a dollar sign in before the password (which I was allowed to paste!) and orf we jolly well go.

Well so far, so good. It’s survived a few quick snoozes… but this is a pretty shoddy bit of user-interface design from Apple. Why do they seem to have three different places you can enter a WEP password? In fact there are four if you count keychains, which I didn’t even look into. And the password only seems to stick if you enter it in one of them (System Preferences > Network > Airport > Configure), which just plain daft. C’mon, Apple, I thought you were all about making technology easy to use?!