java: not found Error when Running Bash Scripts

Creating, Editing and all questions about workflows

Moderator: xonaadmin

java: not found Error when Running Bash Scripts

Postby xonaadmin » Tue Jul 01, 2014 8:17 am

I am trying to execute a Bash script that I have in a directory on another server running the basic agent, I have looked at your documentation but does not give guidance on this and I cant search your documentation unless I just cant see the search bar?.

I have tried two ways to execute the script

First by entering the commands in the Command section as such:

cd /home/user/Scripts/IQRetail_Main; ./IQRetail_Main_run.sh

Error Message:

Task Id: b3eb9b84-fec5-11e3-9d5a-42010af09dee
Task Name: ETLRoutines
Command: cd /home/user/Scripts/IQRetail_Main;./IQRetail_Main_run.sh
User: user
---
./IQRetail_Main_run.sh: 4: ./IQRetail_Main_run.sh: java: not found

If I execute this command on the other machine itself then it works but not if I do it through Situate in the workflow.

Second Way, is to seperate the commands in the Embed Script section as such but I get the same errors.
xonaadmin
Site Admin
 
Posts: 42
Joined: Wed Aug 28, 2013 9:20 am

Re: java: not found Error when Running Bash Scripts

Postby xonaadmin » Tue Jul 01, 2014 8:19 am

Looks like your script cannot find java on the search path.

When you login to a UNIX box, there are certain files in your home directory, .bashrc and .profile that are executed to set things like your command search path ($PATH) and other variables. Situated does not read these because in an ideal production environment, you don't want to be dependent on things that can be changed by uses who may not be thinking about how those changes affect scheduled workflows. Therefore, it's kind of a best practice to have the production scripts specifically set all the things they are dependent upon. BTW: It's also best practices to setup a "service account" -- a user account not tied to any real user, but established as "the" user to run all your production "stuff". This way you can toy around with things in your "steven" account and keep the other account tightly controlled.

But of course there is the "ideal" and what "is".

What I would suggest to you is this... (and it gets a little long, but if you do it this way, it will be more stable and easier to manage in the future. And if you used cron or any other, you'd end up doing this, too.)

1. Go look at your .profile and .bashrc files. You'll find they set some variables like PATH, maybe JAVA_HOME, etc. Typically, there is a PATH=$PATH:.....<lots of other stuff> This one probably has the location of your java JRE on it. Also JAVA_HOME is often used so Java can figure out where it's installed.

2. Copy these to a file and call it something obvious like "situate-profile" and place it in your scripts directory.

3. In the "Environment" section set a variable, ENV to /home/steven/Scripts/situate-profile. This tells situate to process this file first to setup you "environment" like paths, etc.

4. Set another variable "PWD" to "/home/steven/Scripts/IQRetail_Main". This tells situate to run in the IORetail_Main directory.

5. Remove the "cd" because this is now handled by #4. Your command can now simply be ./IQRetail_Main_run.sh"

You can then use the same situate-profile for all your commands and only change it when you need to upgrade java or whatever.
xonaadmin
Site Admin
 
Posts: 42
Joined: Wed Aug 28, 2013 9:20 am

Re: java: not found Error when Running Bash Scripts

Postby xonaadmin » Tue Jul 01, 2014 8:24 am

Seems as though I get stuck at ever stage...Ok, next issue:

I create a workflow called Run and it is supposed to run three other workflows. However when I came in this morning most of the edges had not run.
xonaadmin
Site Admin
 
Posts: 42
Joined: Wed Aug 28, 2013 9:20 am

Re: java: not found Error when Running Bash Scripts

Postby xonaadmin » Tue Jul 01, 2014 8:25 am

In workflow speak, tasks are connected by edges to form "sequences". As sequences run, you can think of a baton being passed from task to task along the edges. When a task completes, each edge coming from the completed task is evaluated to determine if the baton can be passed along it. There is only one baton. The "first" successful edge wins and the baton is passed. So, in your workflow, only Edge_2, Edge_3 or Edge_4 will run.

What you need is a "Split Task". A split and join form the beginning and end of a set of "sub sequences" that are executed in parallel.



The baton is passed from Task_1 to Task_2. Task_2 is a split. It creates three new batons one for each edge off of it and passes them to Task_3, 4 and 5. The batons collect again at Task_6 and the original baton that reached Task_2 continues from Task_6.

In this case, the "status" of task 6 is success if task 3, 4, and 5 succeed.

Anyway, surround your three tasks with a split and join like the picture above and it will do exactly what you want it to do.

For more info on this topic..

http://www.xonasoftware.com/doc?topic=splits-and-joins

When you configure the split, just select "Follow Each Path"




When you configure the Join, all you need to do is set the matching split.
xonaadmin
Site Admin
 
Posts: 42
Joined: Wed Aug 28, 2013 9:20 am


Return to Workflows

Who is online

Users browsing this forum: No registered users and 1 guest

cron