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 😬)