Page 1 of 1

Using relative paths in job definition and inside scripts

Posted: 25 Mar 2019 10:04
by Dilbert
Hello all,
we are facing the following problems with running Control-M jobs on AIX machine, Control-M version 9.x
1. If we define job as "Command", ev-JOberything works fine. The syntax of command is: cd /app/t1/ppt && ./batch/JOB01
No Pre-execution command is used.

2. If we define job as Script, the syntax is:
File path: /app/t1/ppt/batch
File name: JOB01

EVerything works fine until JOB01 starts to execute outer script (job) - JOB02 - which is defined inside script of JOB01 as the following:
EXEC batch
JOB02 successfully started but fails, because it can't find directories needed to execute script. The developers used relatzive paths in all their scripts and there is no way to change that.
After JOB02 started to execute (it started from JOB01 script), it fails with error: can't find directories.

As I said in first scenario, JOB01 successfully started JOB02 from inside script/program, and JOB02 finish OK, that means that JOB01 also finish OK. But that works only if we use COmmand in job definition.
But we wants to use Scripts in job definition because this give us more flexibility.

Any ideas how to successfully execute JOB02 (it started OK, but fails to find folders because of relative paths) without using absolute paths in development?

Thanks in advance,

Re: Using relative paths in job definition and inside scripts

Posted: 26 Mar 2019 9:16
by fyot
Hi Igor

Hope your are well ;-)
Only way I can suggest is :
Is JOB1 script, set a variable reading local path as with pwd command.
And add this variable in ./batch/ command as for instance (in ksh):

PATHLOC=$( cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P )
./batch/ ${PATHLOC}