Read the file in UNIX without Using Unix Command (may be Datastage routine)

断了今生、忘了曾经 提交于 2019-12-24 20:21:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!