Some old Windows batch file tricks

Some very old snippets I used while writing batch files to simplify work.

Parsing date to variables:

rem get name of the day of the week
for /f "tokens=1-4 delims=/ " %%a in ("%date%") do (
Set _wd=%%a
Set _dd=%%c
Set _mm=%%b
Set _yyyy=%%d
Set _dt=%_yyyy%-%_mm%%_dd%

Checking which drive specific volume label is mounted on:

echo Checking drives...
for %%a in (d e f g h i j k l m n o p q r s t u v w x y z) do (
echo %%a:
Set _i=%%a
if exist %%a: vol %%a: | find /i "is IPOD" >nul
if not errorlevel 1 goto :ok

Creating sequential file backups – log rollover

if not exist "%~1" goto :eof
Set $i=
if exist "%~1.bak%$i%" (
Set /A $i+=1
goto :cycle
rem call :out Making backup to: %~1.bak%$i%
echo Making backup to: %~1.bak%$i%
ren "%~1" "%~nx1.bak%$i%"
goto :eof

Writing output to file log and console at the same time:

rem changed logic to fix no-log case
if "%_log%"=="" Set _log=nul
if "%*"=="." (
echo. >>"%_log%"
goto :eof
echo %*
echo %* >>"%_log%"
goto :eof



Transaction tracing in complex multi-tier applications

Interesting, it might be worth to do a small wright up on this, but the technique for tracing requests across multiple systems was available for quite some time and is used in various places. But AWS just implemented this on their load balancers only recently: Elastic Load Balancing support for request tracing
This should help in diagnosing various issues with application performance…

Open Source… wars?

Ok, its been a while since I posted here, but this is not the reason not to post again… and again 🙂
Many post to social networks, but I don’t think that good technical discussion belongs there.

Anyway. Want to touch on hot topic recently – wars in some open source projects. Don’t really want to get on either side of those (that is not that simple), but examples concern me a lot:

  1. Bacula backup vs Bareos – who stole what?
  2. pfSense protecting their trademark by requiring written agreement to get access to their build tools

Both projects are flagships in their respective areas (backup and firewalls), both trying to get more from commercial operations – maybe that’s the problem?

Contributor took our code and forked it? So what? Wasn’t it open source? Oh, you had some contributions, which were not open source? Because you want to make more money from commercial product? Yes, I understand, but people, who supported this project for a long time want those improvements too and there was nothing released for “community edition” for quite some time. It sad. Reading posts by the owner of Bacula just gives a feeling of someone desperately trying to save the face.

pfSense firewall trying to protect its own trademark? Maybe, but asking to remove community-supplied build, which many were asking for (which added Hyper-V drivers) and then trying to justify letters from lawyers  – looks silly and just shows that intent to get code away from community is there.

I do not have anything against making money on open source projects… but I feel that the community should have higher priority than profits. Maybe non-profit is better way to go, but that’s not what people, owning such projects really want – they want to make more money… and maybe sell off to some big corp later – to win a fortune.

Its possible I am wrong. But the above is the result of reading news and discussions.


SSL Browser Root Ubiquity – is it real?

I haven’t posted in a while, so this is a good post to revive this blog.

Just run across a post onVeriSign’s (now Symantec) blog.This is former Tim Callan’s SSL blog, was quite interesting to follow. However, Tim Callan left Symantec recently, so different people now write posts for it.

Regardless… Here is the post in question:  The SSL Blog – Online Security

First, I wanted to post a comment to that entry, but I couldn’t – blog engine told me that:

Your comment submission failed for the following reasons:
Text entered was wrong. Try again.

Doubt this is AI 🙂 just comments are broken in such funky way, so here is my response:

  1. You can’t say “more than 1 in 10 visitors to this site were being shown a message” based on “IE6 which still enjoys nearly 11% of worldwide browser market share” – you do not know what is the share of IE6 users on the site in question, it very well could be 0%.
  2. Going forward, new CAs will rise and they won’t have their new roots in old browsers – because there is no time machine to go back and put them in.
    This does not make those new CAs less trusted than the old ones.

I guess, Symantec does not like competition and uses every opportunity to poke at rivals.