The heart of the system I use for using OS grid references is from the CPAN archive of Perl modules.
At http://search.cpan.org/~pkent/Geography-NationalGrid-1.6/ you will find the relevant modules. If you are unfamiliar with Perl you will need to know that Perl modules are arranged in directory structures that mirror their names. Geography::NationalGrid therefore refers to a file called NationalGrid.pm (note the .pm extension) in the directory Geography. Within Geography you also need a NationalGrid directory containing GB.pm and IE.pm.
To use the modules, use the file you can download here (save it as osgb.pl) as a command line utility, and ensure that the Geography directory is in the same folder. The script accepts six-figure grid references, with a preceeding letter pair to denote the relevant 100km grid square:
>perl osgb.pl nc123456 58.3589211877188 -5.20870388762637 >perl osgb.pl se123456 nc678567 53.9062116134846 -1.81275809170673 58.478799669197 -4.26736536540815