Categories
technology

Which command in DOS

I’ve been told that I should add more of the little programming hints and tips that I used to come up with during my reearch days to this site. Well here’s something I was playing around with today that’s useful for many windows developers. Like many programmers I’m often more comfortable at the command line than using some funky GUI where I have to drag (or learn so many command alias key-strokes that I may aswell be at the console anyway).
I was stuck for a UNIX version of the which command. According to man which this command

Which takes a series of program names, and prints out the
full pathname of the program that the shell would call to
execute it. It does this by simulating the shells search-
ing of the $PATH environment variable.

Replicating this functionality using DOS batch ain’t that bad…

@ECHO OFF
rem Sanity check OS version and arguments.
IF "%OS%"=="Windows_NT" (SETLOCAL) ELSE (GOTO Syntax)
IF "%~1"=="" GOTO Syntax
IF NOT "%~2"=="" GOTO Syntax
ECHO.%1 ¦ FIND /V ":" ¦ FIND /V "\" ¦ FIND /V "*" ¦ FIND /V "?" ¦ FIND /V "," ¦ FIND /V ";" ¦ FIND /V "/" ¦ FIND "%1" >NUL
IF ERRORLEVEL 1 GOTO Syntax


SET Found=
rem Get the short name for the current directory
COMMAND /C REM
rem Search CurrentDir, path and pathext for the file
FOR %%A IN (%CD%;%Path%) DO FOR %%B IN (.;%PathExt%) DO IF EXIST "%%~A.\%~1%%~B" CALL :Found "%%~A.\%~1%%~B"
rem Display the result
ECHO.
IF DEFINED Found (ECHO.%Found%) ELSE (ECHO -None-)
rem Done
GOTO End


:Found
IF DEFINED Found GOTO:EOF
rem Store the first match found
SET Found=%~f1
GOTO:EOF
:Syntax
ECHO.
ECHO WHICH, Version 2.00
ECHO UNIX-like WHICH utility for Windows NT 4 / 2000 / XP
ECHO.
ECHO Usage: WHICH program_name
ECHO.
ECHO Specify program_name with or without
ECHO extension and without a drive or path.
ECHO Just like the UNIX command. (no wildcards please)


:End
IF "%OS%"=="Windows_NT" ENDLOCAL

Categories
technology

How to distribute an atomic bomb!

This post is actually about U2’s new record “How to Dismantle an Atomic Bomb” which is currently spreading like wildfire on certain well-known P2P networks. The problem, apart from the obvious copyright infringements, is that the record hasn’t even been released yet. It’s due for release the 22nd of November. However, a copy of the album dissappeared at a photo shoot and since then there’s been intense speculation about whether the band would bring forward the release date. No decision has been made as yet. More info at the reg..

Categories
technology

VoIP battle is really heating up in the US … but where’s the FCC going with all this?

The Federal Communications Commission (FCC) have decided that individual states cannot impose additional restrictions on VoIP service providers. This follows an attempt by the Minneapolis public utilities commission to force Vonage to abide by the same rules as existing telephony service providers. The FCC overruled deeming that this stance was “inconsistent with the FCC’s deregulatory policies”. More information on the reg. This is a fascinating story as the implications of this ruling are unclear. The FCC’s policies to-date regarding VoIP are supportive but not coherent. It’s very much a wait-and-see approach rather than a strategy promoting adoption of VoIP while reasonably compensating existing operators for the user of their network. This kind of sustainable policy is required to ensure that VoIP services are deployed in a safe and responsible manner with the reliability and security that users expect.

Categories
humour

Ill Will Press

Very funny and profane humour from Illwillpress.com. An particular favourite of mine is the tech support one. Like much of the best satire there’s serious social commentary here masquerading as comedy like the remark about the indian tech support getting $20 a week (about the same as their outsourced US counterparts used to get an hour). If ground-breaking US-satirist Bill Hicks was alive today I reckon he’d sound very much like Germaine on iwillpress.