Run shell script in Workspace 6


Writing a follow-up post for a blog post four years and eight months old, never thought.

Someone reached out to me asking “How can I run shell script in the workspace?”. I asked her to try changing the executable to use sh instead of cmd and she had some issues making it work.

She eventually got it working, and I thought maybe a follow-up post was due.

If you know about “Generic job applications” or if you have read the previous posts, then you know what I’m talking.

If not, then please read about generic job applications.

What we are going to do is create a generic job application in Workspace and run a shell script in Workspace!!

Command template is different from all the other scripts. We need an executable to run shell scripts ($CMD and /bin/sh), we need a shell script ($PROGRAM – the script which we are importing), and parameters if any.

Now if you are using a different shebang in your script, you’ll have to use that executable path. If needed you can create Variables here and refer them in the script by using “$.” E.g., If I create a variable called Application, then I can use that in my script as $Application.

Now that we have the job let’s create a shell script.

I’m going to call the OutlineLoad utility to export dimensions.

Application name, Dimension name, and log file location are parameters.

Let’s import this file into Workspace.

Select the generic job as “Job Factory Application.”

Now let’s navigate to 4. Parameters,  You can define parameters in this section.

You can use Text or Pre-Determined values.

Once done, complete the import.

Order of the prompts is significant as we are using positional variables in the script. If we move Dimension down, then the script will try to extract the log name 😉

Time to run the job.

Users can select/enter the prompts and execute the job.

Once done you’ll get a Table of Contents windows where you can see a stdout, stderr (if present), and any log files.

I did get a stderr file when I ran OutlineLoad without /-O switch. Since this is an extract maintaining the order is not needed, and the message is routed as an error.


After adding /-O switch in the script and reimporting it, here is the TOC.


Yes, it allows you to download the exported CSV file!!!


You can download the file by opening the CSV file and saving it. (Yes it was 2 in the morning 😬)

Advertisements

About Celvin Kattookaran

I’m an EPM Consultant, my primary focus is on Hyperion Planning and Essbase. Some of you from Hyperion Support team might recognize me or have seen my support articles, I was with the WebAnalysis Support Team. I'm an Independent Consultant with “Intekgrate Corporation” based out of Aurora office. I’m from God’s Own Country (Kerala, India), lived in all southern states of India, Istanbul and Johannesburg (and of course United States). I’m core gamer :) and an avid reader. I was awarded Oracle ACE Director for my contributions towards EPM community.


Leave a Reply

6 thoughts on “Run shell script in Workspace

  • Todd Kennedy

    Nice post, I started running powershell script from Workspace with enbedded Maxl code. Did you know you can nicely pass a string of Maxl code into Maxl from STDIN and run it like that? No need to save a file or run from physical files. its a beautiful thing….

  • Todd Kennedy

    You could but the default string field in workspace would be too cumbersome to add maxl like that. Maybe if you had a custom input form that might work.

    My idea was to keep all relevant code together. So powershell script Maxl code and whatever else you need in there is all self contained within the Powershell code.

    Here is the code to simply test an essbase login. So in workspace I add the username , password, server in connection details for the Generic Job. Works great if you want to hid the password and detail from anyone using the script. This script also filters the output and replaces the password with ‘XXXXXXXXXX’ . I use it in a SOX environment so that is crucial to hide the password.

    # Script to test essbase login
    # Maxlcode is embedded within the script
    # parameters are cmdline arguments
    [CmdletBinding()]
    param (
    [parameter(Mandatory = $false, Position = 1)][string]$username,
    [parameter(Mandatory = $false, Position = 2)][string]$password,
    [parameter(Mandatory = $false, Position = 3)][string]$server
    )

    $EPMOracleInstance = $env:EPM_ORACLE_HOME

    $MaxlCode = @”
    set timestamp on;
    set message level all;

    login $username $password on $server;
    IfError ‘loginErr’;
    exit 0;

    Define Label ‘loginErr’;
    echo “Error Logging in $username to $server”;
    exit 2;
    “@

    try {
    $exe = “$EPMOracleInstance\Products\Essbase\EssbaseClient\bin\startMaxl.cmd”
    # Maxl option -i accepts maxl script from stdin
    $CmdOutput = $($MaxlCode | & $exe -i)

    # Mask password in output
    $CmdOutput | ForEach-Object { $_ -replace “$password”, ‘XXXXXXXX’ }
    }
    catch {
    Write-Error $_.Exception.Message
    }
    finally {
    # Here we can do some action stuff based on $LASTEXITCODE of Maxl, which comes from whats defined within the maxl script”
    “LASTEXITCODE: $LASTEXITCODE”
    }

  • Todd Kennedy

    Curious, have you ever tried using in Generic Jobs a parameter that was type ‘Choice of Pre-Determined Values’ using a listbox and allow select multiple values? I get nothing passed to my script.