Code: Select all
OutputFile = LogPath:'/':CrossReferenceTable:'_':NaturalKeyColumnName:'_':JobPID:StagePID:'.dati'
HashFile1 = LogPath:'/':DB2Schema:'_':CrossReferenceTable:'_':NaturalKeyColumnName:'_':JobPID:'_':StagePID:'_temp1'
HashFile2 = LogPath:'/':DB2Schema:'_':CrossReferenceTable:'_':NaturalKeyColumnName:'_':JobPID:'_':StagePID:'_temp'
UNIXcmd = 'cat ':TDPATHbin:'/SurrKeyGen_Index_csv | grep -e ':LogSubject:' | grep -e ':NaturalKeyColumnName' '
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
IF ReturnCode = 0
THEN
UNIXcmd = 'cat ':TDPATHbin:'/SurrKeyGen_Index_csv | grep -e ':LogSubject:' | grep -e ':NaturalKeyColumnName:' |cut -d "," -f2 '
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
InputFileName = ScreenOutput<1>
UNIXcmd = 'cat ':TDPATHbin:'/SurrKeyGen_Index_csv | grep -e ':LogSubject:' | grep -e ':NaturalKeyColumnName:' |cut -d "," -f4 '
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
KeyPos = ScreenOutput<1>
UNIXcmd = "echo '$KeyPos' | awk -F ":" '{print NF}' "
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
NoofFields = ScreenOutput<1>
n=1
CALL DSExecute("UNIX", " while '$n' <= '$NoofFields' ", ScreenOutput,ReturnCode)
IF ReturnCode<1> = 0
THEN
UNIXcmd = "echo '$KeyPos' | cut -d ":" -f'$n' "
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
NaturalKeyPos = ScreenOutput<1>
UNIXcmd = " echo ':NaturalKeyPos:' | grep '|' "
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
IF ReturnCode <> 0
THEN
GoTo OutLabel
END
ELSE
UNIXcmd = "echo '$NaturalKeyPos' | awk -F '|' '{print NF}' "
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
NoofColField = ScreenOutput<1>
x=2
UNIXcmd = "echo '$NaturalKeyPos' | cut -d '|' -f1 "
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
y = ScreenOutput<1>
CALL DSExecute("UNIX", " while '$x' <= '$NoofColField' ", ScreenOutput,ReturnCode)
If ReturnCode<1> = 0
THEN
UNIXcmd = "echo '$NaturalKeyPos' | cut -d '|' -f'$x' "
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
z = ScreenOutput<1>
UNIXcmd = 'cat 'TDPATHbin:'/SurrKeyGen_Index_csv | cut -d ,-f"$y","$z" | sed ''s/,//g'' '
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
OutputFile = ScreenOutput<1>
x += 1
END
n += 1
END
END
END
OutLabel:
UNIXcmd = 'cat 'LogPath:'/':InputFileName:' | cut -d "':InputFileDelimiter:'" -f ':NaturalKeyPos:' | sed "s/\"//g" | sed /^$/d > ':OutputFile
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
If ReturnCode <> 0 THEN CALL DSLogFatal('Error when parsing the input file. ReturnCode = ':ReturnCode:', Command = ':UNIXcmd, ProgramName)
** open output file
OPENSEQ OutputFile TO OUTPUTFILE THEN
CALL DSLogInfo('Opened Output File: ':OutputFile, ProgramName)
END
ELSE CALL DSLogFatal('Could not open Output File: ':OutputFile, ProgramName)
** close output file
CLOSE OUTPUTFILE
This is sort of big code which I want to convert but the above is not working at all..
Problems I am facing -
Unable to assign the output of a UNIXcmd to a variable ..so that I can use it in another UNIX command
For ur convenience
TDPATHbin, LogSubject, NaturalKeyColumnName are coming from the Job itself and SurrKeyGen_Index_csv is a file from which I am greping subject and natural key column.
Let me know if more details are required