Page 1 of 1

calling script error

Posted: Thu Aug 21, 2008 4:43 pm
by mystuff
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.

Posted: Thu Aug 21, 2008 6:01 pm
by ksucheta007
Try you using ExecSH in your Before job subroutine rather than a routine to execute the Shell Script .

Posted: Thu Aug 21, 2008 6:37 pm
by mystuff
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

Posted: Thu Aug 21, 2008 6:39 pm
by ray.wurlod
Show us your code, especially that part that assigns the value to UnixCmd variable.

Posted: Fri Aug 22, 2008 9:15 am
by mystuff
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

Posted: Fri Aug 22, 2008 4:42 pm
by ray.wurlod
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).

Posted: Mon Aug 25, 2008 9:30 am
by mystuff
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.