Tag Archives: cmd

PAUSE command moral

Few days ago I created batch file to backup Firebird databases, Subversion repositories and some other data on a new server. During the testing of the script I put PAUSE command at the end, to see the result (or better to say errors). After I was done with polishing it up I created record in Task Scheduler and started test run. Everything finished in a couple of minutes nicely. I left it there, expecting it to do the backup during the night, as scheduled.

Next day I checked the result and the task failed with 0x8004131F aka SCHED_E_ALREADY_RUNNING. I checked CPU and disk utilization and it was clear the backup is not running. Kind of confused I ran backup manually and waited another day. And guess what, same error. As you probably now see, the problem was the PAUSE command at the end of the script. So the task was actually running, and waiting for the input. Clearly visible in Process Explorer.

I removed it and now everything works fine. Such a stupid mistake caused such a confusion. :)

TortoiseSVN PowerShell aliases improved

Some time ago I wrote about creating PowerShell aliases for commit and update for TortoiseSVN. But I needed little bit more flexibility with path so I added a parameter with default to ..

 function fn_update($path = ".") {tortoiseproc /command:update /path:$path}
 function fn_commit($path = ".") {tortoiseproc /command:commit /path:$path}

Managing TortoiseSVN commit and update from command line and creating PowerShell alias

I started to using PowerShell in my development environment simply to learn it a little bit more (though I’m still using the old command from cmd or UNIX) and also to get out of the stone aged cmd. And because I’m using the console a lot – yep, I get used to it on UNIX/Linux machines with terminal access) I was not happy to open explorer just to issue commit or update to/from SVN (these are most common commands I’m using, together with diff in commit window).

And happily TortoiseSVN has a utility to manage most of the basic tasks. It’s called TortoiseProc. To do commit or update in current directory, you’ll simply execute:

tortoiseproc /command:commit /path:.

or

tortoiseproc /command:update /path:.

For a while I was happy with it. But typing it everytime or looking into history (I wish cmd/PS had Ctrl+R as bash has) was not perfect for me. So I started looking for a way to create alias in PowerShell. Some kind of alias. PowerShell, sure, has something like this, I thought. And it has – Set-Alias. Though, limited. If you try to create alias to command with hardcoded parameters, …

set-alias commit "tortoiseproc /command:commit /path:."

… as I was trying, you’ll not succeed. After some searching and trying I found and an idea from Andrew Watt using a function (yes, I’m a PowerShell newbie). It’s easy and convenient to wrap the command into it.

So finally I create PowerShell aliases for TortoiseSVN to nicely support my work from command line:

set-alias update fn_update
set-alias commit fn_commit
function fn_update {tortoiseproc /command:update /path:.}
function fn_commit {tortoiseproc /command:commit /path:.} 

EdmGen on steroids? EdmGen2!

The EdmGen tool available in Entity Framework or simply SP1 installation is good tool for playing with CSDL, SSDL and MSL files. On the other hand, when using Visual Studio you get all these files in one EDMX file. Though it’s just a pack of these two files, you cannot use it as input/output for EdmGen.

Fortunately there’s a solution – EdmGen2. It’s simply EdmGen on steroids. :) EdmGen2 can read and write EDMX files and also translate between EDMX and CSDL, SSDL and MSL files. The source code is also available, so you can use sources as learning material to API in System.Data.Entity.Design.

Logování baťáků

Uchovávám si logy z různých skriptů, které automaticky spouštím pro pozdější prozkoumání. Ale řešil jsem, jak jednoduše zajistit zápis do logu (občas někde něco člověk zapomene) a případně jeho potlačení. Nakonec jsem vymyslel jednoduché řešení:

@echo off 

if "%1" NEQ "CALL" (
call %0 CALL > batak.log
goto finito
) else ( 

 rem prikazy ...
goto finito 
) 

:FINITO