Page 1 of 1

UNIX command output not captured using RoutineActivityStage

Posted: Mon Jul 30, 2007 4:10 pm
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

Posted: Mon Jul 30, 2007 5:18 pm
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...

Posted: Mon Jul 30, 2007 5:44 pm
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>.

Posted: Mon Jul 30, 2007 6:12 pm
by ArndW
Ray - Ahh, missed that. As you noted, often the first line returned from the execute command is empty.

Posted: Tue Jul 31, 2007 8:06 am
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?
-----------

Posted: Tue Jul 31, 2007 3:44 pm
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.

Posted: Tue Jul 31, 2007 4:42 pm
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.

Posted: Wed Aug 01, 2007 7:31 am
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!

Posted: Wed Aug 01, 2007 3:28 pm
by ray.wurlod
Now change output<1> to Convert(@FM,"~",output) in DSLoginfo() and show us what gets logged.

Posted: Wed Aug 01, 2007 9:01 pm
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!!

Posted: Wed Aug 01, 2007 11:35 pm
by ray.wurlod
It was always being captured. You just weren't looking at it all.