问题
I have a file in a Unix path which has data like: 2019-06-21,2019-06-22|2019-06-22,2019-06-23
I want to read this date and pass this to User Variable Activity .
I am not allowed to Use ant Unix command to read the file.
I read some forum and found that it can be done by routine activity,but not sure where to write the routine and whats the routine name.
Can anyone help in this
* open FinaltestOut.txt
OPENSEQ /home/shivam : '\' : FinaltestOut.txt TO H.FinaltestOut.txt THEN
CALL DSLogInfo("******************** File " : FinaltestOut.txt : " opened successfully", "JobControl")
END ELSE
CALL DSLogInfo("Unable to open file", "JobControl")
ABORT
END
READSEQ FinaltestOut.txt.RECORD FROM H.FinaltestOut.txt ELSE
Call DSLogWarn("******************** File is empty", "JobControl")
END
firstline = Trim(FinaltestOut.txt.RECORD[1,32]," ","A") ******* will read the first 32 chars
Call DSLogInfo("******************** Record read: " : firstline, "JobControl")
CLOSESEQ H.FinaltestOut.txt
回答1:
Step 1 : You can use execute command activity to cat this File. Step 2 : Then use User Variable activity to get the execute command output. Step 3 : Use Field function inside the UV activity to get the desired field.
Note : Here we just use cat command that too in execute command activity. Its the easy approach to resolve your issue.
来源:https://stackoverflow.com/questions/56738373/read-the-file-in-unix-without-using-unix-command-may-be-datastage-routine