on 2024 Jun 04 8:43 PM
In my batch job script, I'd like to implement the logging of metadata to a text file on my DS server. The metadata would include date, time, name, substitution parameter values, datastore field values, etc. Obviously, some of this metadata is already available in the DSMC; by logging it to a text file, however, the results would be more specific, more easily searchable, and available for a longer period of time. Is it possible to write to a text file from within script?
Hi,
I think I have never done this myself within a script.
Have you thought about building a dataflow for it? It should give you the same result.
I.e: Use a Row_Generator that creates one row. Add a Query and add some target columns such as date, config etc. Then Map these fields with the functions from your last post.
Afterwards write into an output .txt file of which the filename is generic and consists of the jobname and runtime or similar.
You could then also use this dataflow generically in all of your jobs.
Edit: Had some time to check myself - you can do the following in a script:
$sysdate = sysdate();
exec('cmd', 'echo Date of Execution: [$sysdate] > //<YourPath>/DIR1/DIR2/Testlog.txt' ,8);
Or if you do not want to declare each and every variable within the Job Object:
set_env('DATE', sysdate());
exec('cmd', 'echo Date of Execution: '||get_env('DATE')||' > //<YourPath>/DIR1/DIR2/Testlog.txt' ,8);
Of course you can add any Parameter you want to this - that's just the baseline. Use ">" to write to file or ">>" to append to file.
Julian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks! I saw both of those methods prior to my original post.
Setting up a flat file and a dataflow seemed cumbersome; I also wasn't sure what to use as the source of the query transform.
I was hoping for an equivalent of the print() function but that writes to a file. I guess re-directing to a text file the output of an echo command is the next best thing. 🙂
User | Count |
---|---|
62 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.