Wednesday, December 26, 2012

Getting started with PowerShell in Windows 7

Enabling it...
  • Choose Start > All programs > Accessories > Windows Powershell
  • Right-click on Window Powershell and (this is important) choose Run as Administrator
  • Type and press Enter: set-executionpolicy remotesigned
  • Type and press Enter when prompted: y
  • Type and press Enter: exit
Running a PowerShell script
  • C:\> powershell c:\pathtoshell\shellname.ps1

Thursday, December 20, 2012

Stumbled upon iText

I found iText when I was looking for something else.  This let's you write PDFs from within Java.  VERY COOL!  I know I will be using this!

Easy to install.  I downloaded itextpdf-5.3.5.jar, copied it to my WEB-INF/lib, copied a sample program from the website (see links for "iText in Action" book for source code), compiled, and ran.  Bam! First PDF from a Java program.

I ordered "iText in Action" from Amazon.  About $20 for a used book.

First time with JavaMelody

I was asked to look into JavaMelody as a tool for monitoring our web application.  This couldn't be easier. 
  • Go to
  • Follow links to download javamelody-1.42.0.jar and jrobin-1.5.9.jar
  • Copy jars to the WEB-INF/lib folder (I did this in Eclipse)
  • Restart server
  • Monitoring available at http://your.apps.url/YourAppContext/monitoring
That's all there was to it.  It can get more sophisticated if you want -- see Users Guide -- but you don't have to.

Friday, December 14, 2012

Passing unknown number of parameters to a program through a batch file

My system has a process which calls other programs, and the program to be executed and its parameters, whose number varies, is all database driven.  So how do I say "pass whatever parameters you got to the program"?  Answer: %* (percent-asterisk) means ALL parameters.  So I make sure the first parameter is the name of the program to be called, followed by all other parameters.  Nice trick.

Saturday, December 8, 2012

How to echo a greater than or less than sign in a DOS batch file

To echo a greater than or less than sign in a DOS batch file, use a carat, as in ^> or ^<.  If you do not do so, the greater than or less than sign will be interpreted as redirection.  To echo a carat, use two carats, as in ^^.  Recall a single carat is used to continue a DOS command on another line.  Also use the carat to escape the piping symbol.

Friday, December 7, 2012

Accessing other DBMS from SAS

This came up when I recently had to read a Netezza table from SAS.  When accessing other DBMS from SAS, PROC SQL is preferred over the use of a DATA step.  With PROC SQL, SAS passes the SQL to the other DBMS and the DBMS returns only the result set to SAS.  With a DATA STEP, the other DBMS must pass the entire table to SAS for processing.

Monday, December 3, 2012

Include contents of .txt file within a .bat file

I have stored some batch file commands in a .txt file.  If I reference that file from another .bat file (thru a "call") the .txt file simply opens in Notepad.  I want to execute these commands from another .bat file; that is to say, I want to "include" them in another batch file.

This would have been simple if I had ended the second file with .bat instead of .txt, but I had a good reason for not doing so.  I want the user to be able to view the contents of this .txt file after the fact, so I want it to open (when selected through a custom built UI) in Notepad, not execute.  I found some very sophisticated solutions on the web, but they were much too complicated.  Here is my trivial solution.

Contents of to_be_included.txt:

   @set "first=x"
   @set "second=y"

Contents of do_it.bat:

   @echo Start %0
   @type to_be_included.txt > to_be_included.bat
   @echo  exit /b >> to_be_included.bat
   @call to_be_included.bat
   @echo I got %first% and %second%.
   @echo End %0

Results of running do_it.bat:

   Start do_it
   I got x and y.
   End do_it

Yes, it creates a superfluous .bat file, but for my purposes that's not a problem as my app will clean up after itself anyway.

Welcome to "The Legacy Learner"

Last night my wife and I saw "Julie and Julia". I expected a very boring chick flick, but in fact I really liked it. As I was walking this morning, it occurred to me that I need to start a blog too. A little background information is in order....

Last week I completed the last requirement for my third masters degree. I have long considered going for a doctorate, and I even signed up for two classes over the summer, but I ended up dropping both of them. I was disappointed in the (lack of) instruction and in the (unrealistic) work load. From what I have seen, a doctorate in this particular department is a whole lot of "read these books, write some reflections, read your peers' reflections, write a literature review, and prepare a short presentation to be presented to your peers when we meet again four weeks from now."

It's not that I think research is ineffective, it's just that I find it to be a very inefficient way to learn. It has a very poor ROI; that is, return of learning on (time) invested. I can do it. But at my age (52) I guess I just don't want it bad enough.

But I need goals. I am like Julie in the movie (point of clarification: I am male.) I need to feel as though I am progressing. Standing still scares the hell out of me. So I decided I would make it a goal to spend at least one hour per day learning. And I would blog about it.

Why "The Legacy Learner"? Well, first, I was sure "The Lifelong Learner" would be taken (it was). Second, most of my learning will likely be technology oriented. I am an old mainframe programmer, and have worked on my share of "legacy" systems. I have updated my skills -- better than most of my contemporaries -- but I'm still not where I want or need to be.

I hope to add a tiny "morsel" of learning to this blog on a daily basis. " Bon apetite!"


Well, this is embarrassing.  I wrote that four years ago.  I have since completed half of my fourth masters degree.  Time to get started.