ETL file parsing using powershell script - parsing

#Defining the etl file
$etlFile = 'test.etl'
#Retrieving the content
$log = Get-WinEvent -Path $etlFile –Oldest
Is there any other way of parsing .etl file to read etw events?

There is no built in command for reading an etl file with PowerShell but calling tracerpt.exe in windows\system32 for converting the etl file into xml (the file is always called dumpfile.xml) seems to be a simple solution:
tracerpt.exe .\WindowsUpdate.20220813.100210.641.1.etl -lr
([Xml](Get-Content .\dumpfile.xml)).Events
([Xml](Get-Content .\dumpfile.xml)).Events.Event
([Xml](Get-Content .\dumpfile.xml)).Events.Event.EventData
([Xml](Get-Content .\dumpfile.xml)).Events.Event.EventData.Data
etc.
See also Converting ETL to XML in powershell using traceprt, issues with dashes and spaces in arguments

Related

Lua io.write() not working

I am using a luvit Lua environment to run my lua code through my control panel. I am looking to write to a .txt file, but with the simple code that i am running, its not working.
The reason I wish to write to a .txt file is to log notices from my Discord Bot I am working on in the Discordia library.
I have a folder called MezzaBOT. In this file i have a write.lua file and also a log.txt file. I have this simple code in my write.lua file:
io.output('log.txt')
io.write('hello\n')
io.close()
I then run in my command promt with Luvit environment:
>luvit Desktop\mezzabot\write.lua
I don't get any errors but the log.txt file continues to stay empty. Am I missing a line in my code, or do i need to access log.txt differently?
edit: my new code is the following
file = io.open('log.txt')
file:write('hello', '\n')
file:close()
and it is not making a new line for each time with \n
edit B:
Ok, i found my problem, its creating a log.txt in my C:\Users\PC.
One other problem is when writing, its not making a new line with the \n. Can someone please help me?
Lua, by default, opens files in read mode. You need to explicitly open a file in write mode if you want to write to it (see manual)
file = io.open('log.txt', 'w')
file:write('hello', '\n')
file:close()
Should work :)

Using Jena to convert an owl file to N-Triples from terminal returns an empty file

I have generated an owl file using this generator http://swat.cse.lehigh.edu/projects/lubm/
I want to transform the file in N-triples and have done it before using
$ riot -out N-TRIPLE ~/lubm20/*.owl > lubm20.nt
for some reason now I get an empty file (lubm20.nt)
and when I use
$ rdfcat -out N-TRIPLE ~/lubm20/*.owl > lubm20.nt
I get this error
Exception in thread "main" org.apache.jena.riot.RiotException: <file:///root/lubm20/classes\University0_0.owl> Code: 4/UNWISE_CHARACTER in PATH: The character matches no grammar rules of URIs/IRIs. These characters are permitted in RDF URI References, XML system identifiers, and XML Schema anyURIs.
at org.apache.jena.riot.s5ystem.IRIResolver.exceptions(IRIResolver.java:371)
at org.apache.jena.riot.system.IRIResolver.resolve(IRIResolver.java:328)
at org.apache.jena.riot.system.IRIResolver$IRIResolverSync.resolve(IRIResolver.java:489)
at org.apache.jena.riot.system.IRIResolver.resolveIRI(IRIResolver.java:254)
at org.apache.jena.riot.system.IRIResolver.resolveString(IRIResolver.java:233)
at org.apache.jena.riot.SysRIOT.chooseBaseIRI(SysRIOT.java:109)
at org.apache.jena.riot.adapters.AdapterFileManager.readModelWorker(AdapterFileManager.java:286)
at org.apache.jena.util.FileManager.readModel(FileManager.java:341)
at jena.rdfcat.readInput(rdfcat.java:328)
at jena.rdfcat$ReadAction.run(rdfcat.java:473)
at jena.rdfcat.go(rdfcat.java:231)
at jena.rdfcat.main(rdfcat.java:206)
The generator would generate a well known semantic web benchmark dataset so how can it have
UNWISE_CHARACTER s?
edit:
for the question asked
I used this line to generate the *.owl files
java edu.lehigh.swat.bench.uba.Generator -onto http://swat.cse.lehigh.edu/onto/univ-bench.owl univ 20
then moved the *.owl files to lubm20 folder
I used rdf2rdf instead of jena
java -jar rdf2rdf-1.0.1-2.3.1.jar /lubmData/lubm100/*.owl lubm100.nt
worked like a charm
enter link description here

Using command line to copy txt of many files and create new txt with all text

So as an early task at a new junior developer position I was asked to go through and update thousands of old parameter data types in various stored procs. I did all the updates and loaded them to the team server and now have to push them into our SQL server so they will compile.
Last night my boss eluded to how I could pull the modified procs into a directory, then use command line to copy all text and create a new txt file that could be opened in SQL to run a mass update basically in batch mode per database.
I have almost no command line experience, can someone give me a quick overview.
My Pseudocode:
Open command line window in my UpdatedProcs folder, copy text from all files in same directory, create new text file containing all of the text (name of new file doesn't matter). Then open in SQL, look for errors one last time, and finally run.
This seems simple but I know nothing about command line.
Thanks for your help.
Use a for /f loop. You don't even need to copy the files from the subdirectory first. This appends all of the text files in the Temp subfolder (C:\Test\Temp) into a file named summary.log in the current folder (C:\Test):
c:\Test>for /f "tokens=*" %a in ("dir temp\*.txt") do type %a >> .\summary.log
summary.log now contains all of the content of the text files in a single file. You can open it with Notepad or any other text editor.
To run from a batch file, simply change the %a to %%a in both places.
c:\Test>copy con mergefiles.bat
for /f "tokens=*" %%a in ("dir temp\*.txt") do type %%a >> .\summary.log
F6 or Ctrl+Z
c:\Temp>mergefiles
Enter
c:\Temp>notepad summary.log
Enter

Compare tool with command line for mac

I am looking for command line tool to do diff between two HTML files.
I have analysed kdiff3/command line of bbedit but my problem is dont want to open any GUI.
I want to write a java program to call command line options of the diff program to compare html files and save result in a different file or probably show in a report file.
Any pointers will be very helpful
Thanks
Vishal
If you have xcode installed, you can call up opendiff, it's a (graphical) compare tool from the command line. From it's man page:
opendiff file1 file2 [-ancestor ancestorFile] [-merge mergeFile]
opendiff dir1 dir2 [-ancestor ancestorDirectory] [-merge mergeDirectory]
I thought mac had diff built in. Have you tried using diff from the mac terminal?

Converting images to .xcf format

Is it possible to convert an image, or batch of images, to a .xcf or .psd file? Using ImageMagick's convert tool didn't work, but so far my attempts to look at doing this using gimp from the command line have been unsuccessful.
An answer can now be found here. Put the following code into a script.
gimp -n -i -b - <<eof (let*="" (="" (file's="" (cadr="" (file-glob="" "*.png"="" 1)))="" (filename="" "")="" (image="" 0)="" (layer="" )="" (while="" (pair?="" file's)="" (set!="" image="" (car="" (gimp-file-load="" run-noninteractive="" file's))))="" layer="" (gimp-image-merge-visible-layers="" clip-to-image)))="" filename="" (string-append="" (substring="" 0="" (-="" (string-length="" file's))="" 4))="" ".xcf"))="" (gimp-file-save="" filename)="" (gimp-image-delete="" image)="" file's="" (cdr="" (gimp-quit="" eof<="" pre="">
enter code hereIt's a script that batch converts to any file format that gimp can read. Just substitute ".xcf" on line 2 and ".png" on line 6 for whatever file formats you need

Resources