UNIX command output not captured using RoutineActivityStage

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
harishvardhan
Premium Member
Premium Member
Posts: 14
Joined: Wed Feb 01, 2006 8:50 am
Contact:

UNIX command output not captured using RoutineActivityStage

Post by harishvardhan »

I am using Routine_activity stage to read a flat file in Parallel extender sequence to pass it to DSSendmail.
Here is the BeforeAfter DSSendmail code I have:
-----------

$INCLUDE DSINCLUDE JOBCONTROL.H

* This is just an interlude to the DSSendMail job control function,
* to allow it to be called as a before/after routine:

Call DSLogInfo(DSMakeMsg("InputArgument for the notification file path ":InputArg, ""), "ChevBeforeAfterSendMail")

UNIXcmd = "head -1 ":InputArg

Call DSLogInfo(DSMakeMsg("unix command used is ":UNIXcmd, ""), "ChevBeforeAfterSendMail")

Call DSExecute("UNIX", UNIXcmd, output, SystemReturnCode)
Call DSLogInfo(DSMakeMsg("Output From the unix command --":output<1>:"--System return=":SystemReturnCode, ""), "ChevBeforeAfterSendMail")

ToAddress<-1> = output<1>
FromAddress<-1> = "abc@abc.com"
Server<-1> = "abc.net"
Subject<-1> = "HI.This is a test. Please ignore"
MessageBody<-1> = "Test. To be ignored"
MailString = "From:":FromAddress:"\nTo:":ToAddress:"\nSubject:":Subject:"\nServer:":Server:"\nBody:":MessageBody
Call DSLogInfo(DSMakeMsg("Mail String used for DSSendMail ":MailString,""), "ChevBeforeAfterSendMail")
MailString_test="From:":FromAddress:"\nTo:snoc@abc.com\nSubject:":Subject:"\nServer:":Server:"\nBody:":MessageBody
* Reply = DSSendMail(MailString)
Reply = DSSendMail(MailString_test)
Begin Case
Case Reply = DSJE.NOERROR
ErrorCode = 0 ;* set to 0 - file checked OK, job continues
Case @True
ErrorCode = 1 ;* some other error, such as bad InputArg, stops the job if this is an after routine
End Case

-----------
The InputArg is the pathname of the file.
This is the error I get in the Director.
-------------
Seq_Notification_List..JobControl (ChevBeforeAfterSendMail): Output From the unix command ----System return=0
-----------
So clearly the output from the DSExecute is not captured.
Interestingly, if I hard code the path of the file instead of passing it as an argument then it works fine.
Can anyone tell me where the problem is ?

Thanks for looking into the problem.

--Sree
Harish vardhan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since you are logging the UNIXcmd variable in an informational message, could you post that output for a run that doesn't work? The output goes to stdout, so perhaps this command is returning nothing to standard output...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is returned through SystemReturnCode argument? This is the exit status of the UNIX command. Also, try leaving off the <1> from the output argument when logging the value; the command's first output character may have been a line feed. Instead of output<1> use just output in DSLogInfo() or Convert(@FM,"~",output) so you can see exactly what IS being returned. Your diagnostic strategy may have masked the fact that you need output<2> rather than output<1>.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Ray - Ahh, missed that. As you noted, often the first line returned from the execute command is empty.
harishvardhan
Premium Member
Premium Member
Posts: 14
Joined: Wed Feb 01, 2006 8:50 am
Contact:

Post by harishvardhan »

ray.wurlod wrote:What is returned through SystemReturnCode argument? This is the exit status of the UNIX command. Also, try leaving off the <1> from the output argument when logging the value; the command's first output character may have been a line feed. Instead of output<1> use just output in DSLogInfo() or Convert(@FM,"~",output) so you can see exactly what IS being returned. Your diagnostic strategy may have masked the fact that you need output<2> rather than output<1>.
I have tried the options Ray has mentioned, but still the output is not captured.

Now I have hardcoded the path of the file instead of an argument to be passed to the routine. This is how it looks now.
------------
UNIXcmd = "head -1 /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN"

-----------
Here the path is /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN
Now the log in the director is :
Seq_Notification_List..JobControl (ChevBeforeAfterSendMail): Output From the unix command --zbil@chevron.com,tbfb@chevron.com,snoc@chevron.com--System return=0
-----------
So the question is the System Return in both the cases is 0. Why does it capture when the path is hardcoded compared to when it is passed as an argument?
-----------
Harish vardhan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since you haven't posted the UNIX command string when you pass in an argument there is nothing that can be done to help.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What do you get when you type this commands at the UNIX prompt?

Code: Select all

head -1 /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN

echo $?
It's impossible to diagnose further without knowing that.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
harishvardhan
Premium Member
Premium Member
Posts: 14
Joined: Wed Feb 01, 2006 8:50 am
Contact:

Post by harishvardhan »

ray.wurlod wrote:What do you get when you type this commands at the UNIX prompt?

Code: Select all

head -1 /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN

echo $?
It's impossible to diagnose further without knowing that.
This is what I am seeing from the unix.
$ head -1 /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN
zbil@chevron.com,tbfb@chevron.com,snoc@chevron.com$ echo $?
0
$


And ArndW-- this is the unix command when the argument is passed to the routine. These are the logs in the director:
Seq_Notification_List..JobControl (ChevBeforeAfterSendMail): unix command used is head -1 /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN

Seq_Notification_List..JobControl (ChevBeforeAfterSendMail): Output From the unix command ----System return=0

The output from the command in the director log is expected like --<output>--. In the log as we can see that its just printing it as ----. Which means its not capturing the output. In both cases the system return is 0.

Thanks!
Harish vardhan
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Now change output<1> to Convert(@FM,"~",output) in DSLoginfo() and show us what gets logged.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
harishvardhan
Premium Member
Premium Member
Posts: 14
Joined: Wed Feb 01, 2006 8:50 am
Contact:

Post by harishvardhan »

ray.wurlod wrote:Now change output<1> to Convert(@FM,"~",output) in DSLoginfo() and show us what gets logged.
Ray,
After I changed the code as above the output is getting captured.
-----------
Seq_Notification_List..JobControl (ChevBeforeAfterSendMail): Output From the unix command --zbil@chevron.com,tbfb@chevron.com,snoc@chevron.com--System return=0
-----------
Cheers!!

Thanks!!
Harish vardhan
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It was always being captured. You just weren't looking at it all.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply