UNIX command output not captured using RoutineActivityStage
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 14
- Joined: Wed Feb 01, 2006 8:50 am
- Contact:
UNIX command output not captured using RoutineActivityStage
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 14
- Joined: Wed Feb 01, 2006 8:50 am
- Contact:
I have tried the options Ray has mentioned, but still the output is not captured.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>.
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
What do you get when you type this commands at the UNIX prompt?
It's impossible to diagnose further without knowing that.
Code: Select all
head -1 /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN
echo $?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 14
- Joined: Wed Feb 01, 2006 8:50 am
- Contact:
This is what I am seeing from the unix.ray.wurlod wrote:What do you get when you type this commands at the UNIX prompt?It's impossible to diagnose further without knowing that.Code: Select all
head -1 /chap/lynx/Data/HOU_Dev/outputfiles/notification_test.LYPBIN echo $?
$ 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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 14
- Joined: Wed Feb 01, 2006 8:50 am
- Contact:
Ray,ray.wurlod wrote:Now change output<1> to Convert(@FM,"~",output) in DSLoginfo() and show us what gets logged.
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: