Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.
Moderators: chulett , rschirm , roy
mystuff
Premium Member
Posts: 200 Joined: Wed Apr 11, 2007 2:06 pm
Post
by mystuff » Thu Aug 21, 2008 4:43 pm
I am gettitng the following error when I am trying to call a script through before job subroutine.
RoutineTest..BeforeJob (): SH: /opt/home/xxx/script.sh -H mass -P parameterfile.txt: not found
When I copy the same from the log and execute on the unix box, this scripts runs fine (to check for any syntax errors).
Within the subroutine I am using DSExecute to call unix command
Code: Select all
Call DSExecute("UNIX", UnixCmd, SystemOutput, SystemReturnCode)
Any idea why I am getting this error.
ksucheta007
Participant
Posts: 1 Joined: Tue Jun 20, 2006 9:32 pm
Post
by ksucheta007 » Thu Aug 21, 2008 6:01 pm
Try you using ExecSH in your Before job subroutine rather than a routine to execute the Shell Script .
Sucheta
mystuff
Premium Member
Posts: 200 Joined: Wed Apr 11, 2007 2:06 pm
Post
by mystuff » Thu Aug 21, 2008 6:37 pm
ksucheta007 wrote: Try you using ExecSH in your Before job subroutine rather than a routine to execute the Shell Script .
whats the difference?? they both mean same.
And I want to log the output of the director + capture the return code, therefore using DSExecute instead of DSU.ExecSH
ray.wurlod
Participant
Posts: 54607 Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:
Post
by ray.wurlod » Thu Aug 21, 2008 6:39 pm
Show us your code, especially that part that assigns the value to UnixCmd variable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mystuff
Premium Member
Posts: 200 Joined: Wed Apr 11, 2007 2:06 pm
Post
by mystuff » Fri Aug 22, 2008 9:15 am
Here is the code
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
UnixCmd=''
ErrorCode=0
RoutineName = "FunctionTest"
pBaseDir=Field(InputArg,"|",1)
hSubject=Field(InputArg,"|",2)
pFile=Field(InputArg,"|",3)
UnixCmd=pBaseDir:"/script.sh "
UnixCmd:="-H ":hSubject:" -P ":pFile
Call DSExecute("UNIX", UnixCmd, SystemOutput, SystemReturnCode)
ErrorCode=SystemReturnCode
Call DSLogInfo(SystemOutput, FunctionName)
if ErrorCode<>0 then
Call DSLogFatal("Error while reading the file","JobControl")
End
Note: there is a space after /script.sh
ray.wurlod
Participant
Posts: 54607 Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:
Post
by ray.wurlod » Fri Aug 22, 2008 4:42 pm
Good, now verify the command that DSExecute is being asked to process. Immediately ahead of it, use something like
Code: Select all
Call DSLogInfo("Command is " : UNIXCmd, "Debugging")
Verify, also, that
/opt/home/xxx/script.sh actually exists at that location. The "not found" error message suggests either that it does not, or that the executing user ID does not have adequate permission to find it (so check the permissions on each directory in that path).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mystuff
Premium Member
Posts: 200 Joined: Wed Apr 11, 2007 2:06 pm
Post
by mystuff » Mon Aug 25, 2008 9:30 am
I checked with DSLogInfo
It issues the command properly
Code: Select all
/opt/home/xxx/script.sh -H mass -P parameterfile.txt
I ran it by copying and pasting it on the terminal.
Regarding permissions. I made all directories and sub-directories chmod 777 . But it still gives the same error.
When I prefixed the UnixCmd with eval it works. But I have seen other codes which works without using eval.