Want to know The Truth About CPM?

07 August 2010

Stupid programming tricks #1

Introduction

This is going to be one of an occasional, short (can it be true), little techniques that I’ve picked up along the way.  This one isn’t even original, but it works so well I just have to write about it.

I had to do an inventory of calc scripts, rule files, and report scripts.

There were lots of them.  Lots.  More than you could ever imagine.  And, I needed to get a list of all of them quickly.

Oh, I could have used the Most awesome excellent Language ever, and entered:
display calculation all ;

But that would only have given me the calc scripts.  What about reports?  What about rules?

I could have used MaxL again with a different display command, display object, but the syntax for that command confuses my simple brain.

A better way

It occurred to me that those items were all available at the OS level as they are all files with .csc, .rul, and rep extensions.

How could I quickly, painlessly, consistently, etc., etc., get this information into a text file so I could hoover it into SQL or Excel to report on?

Why good old DOS, of course.  Yes, I am old enough to remember DOS 1.0, and DOS-compatible PCs (which were not the same as PC compatible), and CPM, and when dinosaurs walked the earth with me and my good buddy down at the quarry, Fredrick Joseph Flintstone.  And I like DOS, heaven help me.  Succinct, powerful-ish, and cryptic.  What’s a hacker not to like?

And guess, what, DOS has this nifty little recursion function called FOR.  If you care to read all about it, type FOR /? at the command prompt on your PC or check out this nice blog series that I wish I had found before I figured this out.

What’s it look like?

So simple it hurts:

for /r %d in (*.msh) do echo %d >> c:\temp\MaxLOutput.txt

Enter that from whatever directory you care to start in and FOR /R will do the rest for every single MaxL script that’s in the descendants of the launching directory.

And here’s the output (I launched it from c:\tempdir):
C:\Tempdir\ODTUG_2009\CatchThatError.msh
C:\Tempdir\ODTUG_2009\connect.msh
C:\Tempdir\ODTUG_2009\disconnect.msh
C:\Tempdir\ODTUG_2009\encryptionpost.msh
C:\Tempdir\ODTUG_2009\HelloMurphy.msh
C:\Tempdir\ODTUG_2009\local.msh
C:\Tempdir\ODTUG_2009\nested.msh
C:\Tempdir\ODTUG_2009\NoError.msh
C:\Tempdir\ODTUG_2009\parameters.msh
C:\Tempdir\ODTUG_2009\parameters_environment.msh
C:\Tempdir\ODTUG_2009\properties.msh
C:\Tempdir\ODTUG_2009\shell.msh
C:\Tempdir\ODTUG_2009\SpoolMe.msh
C:\Tempdir\ODTUG_2009\tobeencrypted.msh
C:\Tempdir\ODTUG_2009\tobeencrypted.mshs
C:\Tempdir\ODTUG_2009\9.2 metaread\Copy of
C:\Tempdir\ODTUG_2009\9.2 metaread\Metaread\deprecated\filename.msh
C:\Tempdir\ODTUG_2009\deprecated\Copy of sample3.msh
C:\Tempdir\ODTUG_2009\deprecated\sample3.msh
C:\Tempdir\ODTUG_2009\deprecated\sample3a.msh
C:\Tempdir\ODTUG_2009\deprecated\sample4.msh
C:\Tempdir\ODTUG_2009\deprecated\sample5.msh
C:\Tempdir\ODTUG_2009\deprecated\sample6.msh
C:\Tempdir\ODTUG_2009\deprecated\sample3.mshs
C:\Tempdir\ODTUG_2009\deprecated\sample3a.mshs
C:\Tempdir\ODTUG_2009\deprecated\sample4.mshs
C:\Tempdir\ODTUG_2009\ODTUG_2009\call_metaread_add_filters.msh
C:\Tempdir\ODTUG_2009\ODTUG_2009\call_metaread_add_filters.mshs
C:\Tempdir\ODTUG_2009\ODTUG_2009\Metaread_Add_Filters.msh
C:\Tempdir\ODTUG_2009\ODTUG_2009\Write_Filters_To_Disc.msh
C:\Tempdir\ODTUG_2009\ODTUG_2009\write_filters_to_disc.mshs

How about calcs?

for /r %d in (*.csc) do echo %d >> c:\temp\CalcOutput.txt

And here’s the output (I launched it from c:\tempdir):
C:\Tempdir\NOTTELLING\NOTTELLING\XPort.csc
C:\Tempdir\NOTTELLING\NOTTELLING\Bad order FinPlan4_GLTest\ActCmbnd.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\GL\GL.ActCmbnd.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\GL\GL.allocav2.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\GL\GL.AllocAvg2.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\GL\GL.FillQBR.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\GL\GL.QBRTEST2.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\GL\GL.X.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\PGM\AdvaLiqn.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\PGM\OPSCopy.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\PGM\PopActE.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\PGM\ProgRecp.csc
C:\Tempdir\NOTTELLING\NOTTELLING\NOTTELLING Backup\NOTTELLING Backup\PGM\RecvBal.csc
C:\Tempdir\NOTTELLING\NOTTELLING\FinPlan4\ActCalc.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\$calc.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\$test.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\71937158.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\AdminOH.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\AggCMth.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\BaseAct.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\BB2YTD.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\BR2.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\CComp.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\ClrAdj.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\Comp.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\Fringe.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\Pipeline.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\RevCycle.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\Revenue.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\Seed7699.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\SeedCalc.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\Taxes.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\Transfer.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\WSGrant.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\YTD2BB.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\Adj_calcs\YTDAct.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\TUSMFRBS_PandL\$calc.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\TUSMFRBS_PandL\$test.csc
C:\Tempdir\REDACTED\Phase I\Adjustment\TUSMFRBS_PandL\$test2.csc

Conculsion

And that’s it – this isn’t Oracle EPM based – it can be for any kind of file.

Not exactly hacking Essbase, but it’s a little out of the ordinary and a *huge* timesaver if you’re trying to get lists fast.

6 comments:

Doug Burke said...

Thank you Cameron! Great post and worth the price of admission.

Bence said...

Cameron,
you can also use the Dir command with the /s option on the more recent versions of DOS/Windows:

dir /s /b *.msh

Cameron Lackpour said...

Bench,

Uh, yes, your way would be much, much easier.

Insert Magyarian equivalent of "Doh!" (maybe it's exactly the same?) and the planting of face into palm.

My only mitigation is that FOR /R is capabable of other cool stuff but indeed, dir *.msh /b /s is significantly simpler.

Regards and thanks,

Cameron Lackpour

Sean V said...

It's these sorts of tips and tricks that are usefull. Kaleidoscope needs a session on "Maintaining your Hyperion Environment" (or some such) with tips/tricks/techniques around maintaince and development of your Hyperion environment.

Alok said...

Is that really works? I mean why you have named "Stupid programming tricks"? Thanks for providing the dos prompt codes for the explanation. I appreciate your writing.
Database Management

Cameron Lackpour said...

Alok,

I'm glad you liked it.

I'm afraid "Stupid Programming Tricks" is a bit of American humor that likely doesn't translate all that well.

Check this out and the allusion should make some sense: http://en.wikipedia.org/wiki/Stupid_Pet_Tricks

As for the code -- try it -- it works. *All* of my code works. At least the stuff you see posted on the web. :)

I've got another Stupid Programming Trick just a rarin' to go, but I'm spacing all of these out -- if I posted everything all at once who would come back for more?

Regards,

Cameron Lackpour