Issue with Shell Escape and @CalcMgrExecuteMaxLScript

Thought I’d post a little tip that could prove useful to others that are looking to use the @CalcMgrExecuteEncryptMaxLFile and @CalcMgrExecuteMaxLScript Essbase functions (CDFs). I often find the ‘shell’ command that is available with MaxL scripting to be very useful. According to the Oracle technical documents the ‘shell’ or ‘Shell Escape’ allows the user to issue operating-system commands directly from a MaxL Shell session. An example MaxL script utilizing the shell command is shown below (Linux-based OS).

Here, the shell statement “shell ‘rm file.txt’” is being leveraged to delete the ‘file.txt’ file using the ‘rm’ Linux command. However, if you try to run this MaxL file from within an Essbase calc script or Planning calc rule you will notice that the ‘file.txt’ file is not deleted. You might think something is wrong with your MaxL file and try executing from an OS command line at which point the ‘rm’ command will work as expected and the file will be deleted. I spun my wheels trying to figure this one out. The problem? You will need to specify the full path to the ‘rm’ command. It seems that the calc functions do not load or use profiles or environment variables when executing the MaxL shell and thus require full paths for any and all commands. Any shell statements should be updated to include the full path for OS commands as illustrated below.

Running the updated MaxL using one of the @CalcMgrExecute functions will now succesfully delete the file specified in the ‘shell’ statement. How about another example.
Let’s say I wanted to use the Linux ‘mail’ command in a MaxL shell statement. Similarly, I would need to make sure I include the full path to the ‘mail’ command.

mail

 

The screenshot below displays a list of the commands in a typical /bin directory of a Linux install.

bin

When trying to use any of these Linux commands such as ‘sleep’ or ‘mail’ via the MaxL ‘shell’ statement in MaxL scripts, the full path (/bin/command) will be necessary if you are trying to run the MaxL using the @CalcMgrExecuteEncryptMaxLFile or @CalcMgrExecuteMaxLScript Essbase functions (CDFs).

My assumption is that a similar practice will need to be used if one is dealing with a Windows environment and attempting to use any of the native DOS or external  commands (dir, del, etc). Here though, you may need to play around with using a combination of the “cmd.exe” command shell and then the DOS command  – shell ‘CMD /C “del file.txt”’ – for example.

ragnar

 

Pete Strayer

About Pete Strayer

Setting aside aspirations to become a professional bass fisherman or race car driver, Pete Strayer instead opted for the glorious career as an EPM consultant. When he’s not making his dad’s secret sloppy joe recipe, you’ll likely find him creating some MDX calculations or exploring new possibilities with Oracle Data Integrator. An Arizona native, Pete’s hobbies include eating (especially pizza or Mexican food), fast cars, HPDE events (google it) and spending time with his family.

2 Comments

  1. Thank you very much!!!
    I was worried trying and trying till I found your post.
    It worked!!!
    Thank you for your help.
    Terrific!

  2. Great, glad you found it helpful David.
    Pete

Leave a Reply

Your email address will not be published. Required fields are marked *