Doxygen command line - error handling - doxygen

I use Doxygen in command line mode(via a batch file scheduled to run at certain time) for generating code documentation.
I supply it with a Doxyfile that has all the settings.
And it overwrites the previously generated documentation for same code.
My problem is, the input location name may change at some time.
So, in the log, doxygen shows that it cannot find ONE of the input locations.
What my aim is that the documentation should be generated/overwritten ONLY IF there is NO ERROR.
There are three possible solutions in my mind(in the order of decreasing convenience):
Interrupt docs generation in case of ANY error.
If its not possible to interrupt the docs generation, I can generate docs in some other place and then replace older ones using simple move command in batch file IF Doxygen has not thrown any errors. For this, I will somehow have to get hold of Doxygen errors in batch file runtime.
Save docs to different folder, save log to txt, scan txt in batch for errors(This, I can do but prefer avoiding)
So, is there any way I can get hold of this error while running Doxygen via batch file?

Related

WinDbg scripting - how to delete a file?

I'm working with an existing framework of WinDbg scripts that go through a series of test scripts Test1.txt, Test2.txt, etc., which are generated by C++ code and which output results.
For example a chunk of one of the test scripts would be,
.if (($spat(#"${var}","18300.000000")==1))
{
.logappend C:\Tests\TestResults.txt
.printf "TestNumber=\t1\tExpected=\t18300.000000\tActual=\t%.6f\t******PASSED******\n",poi(poi(#$t2+#$t6)+0x10)
.logclose
}
I'm trying to add functionality that will create a file whose name displays the current # of the test being run, so that users can see their progress without needing to open a file.
My thought process was that I would set up the script generator, so that at the start of Test #N, it would add a line to the script to create a file 'currentlyRunningTestN.txt', and at the end of Test #N, it would add a line to the script to delete that file. However, I don't see any delete function in the WinDbg meta command glossary: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/meta-commands, or in the list of supported C functions like printf. Am I just missing something, or is deleting files not supported by WinDbg (or equivalently renaming files, which would also serve my purpose?) If deleting/renaming don't work, is there another way to achieve the functionality I'm looking for?
With the .shell command, you can execute any DOS-like command. Although I never tried deleting a file, it should be possible.
As you may have noticed, WinDbg scripting does not always work on first attempt, please make sure your scripting will not result in a big data loss on your customer's PC whilst deleting files.

Reading the last 2 lines of a .log file via Matlab

The problem that I am attempting to solve is as follows:
I have a .log file that is updated every x seconds (an interval that I can change), with updated status information from a piece of test equipment. At each interval, another line is added to the .log file, with the updated information. My goal is to have the most recent status information (the last two lines of the .log file) easily viewable in Matlab.
Here is an example of what each update looks like, in case that is relevant (a single line of text):
What I have tried:
I used the readtable command (shown below) to view the information in the .log file, but that gives me the entire .log file every time the function is called, when I only want/need the last two lines.
data = readtable('FileName.log','FileType','text')
I know that this would be simpler if I was working with a .csv or .xlsx file, but the test equipment only updates the .log file, so I cannot just change the file type, as it would not get updates then.
Any advise would be appreciated.
If the .log file is in plain text format (as I assume based on your code snippet), you can get the last 2 lines of the file by using the following system command in MATLAB:
[status,output] = system(['tail -n 2 ', path]);
Please do keep in mind that this requires the tail command to be available, which is not available in windows by default - however you can get around this by installing a package containing the tail command, for example Cygwin.

Matlab can't find publish file. Where is it?

I have found the publish menu in Matlab. I would like to reference it in my code so as to save output ( without the commands) and all figures. I am using only figure1 throughout. I want to save in two formats pdf and doc.
Where do I put the publish command at the beginning or at the end of my code or putting it another way should I execute the publish commands at beginning? Matlab software keeps telling me it cannot find the file? Further I want to include all graphs. I have added snapnow after each plot.
I have used the following code both at beginning and end of my program. I want to include all graphs but no input commands only output. Options can be seen on edit publishing options window. I tried to start simple.
Code:
publish('c:\data\output.doc')
publish('c:\data\output.doc','doc')
Error message
Cannot find "c:\data\output.doc".
Thank you.
MM

Force overwrite or delete file in use (executable that currently runs)

I'm looking for solution to delete or (preferably directly) overwrite source of an exe file while it is running.
To explain further before you get it all wrong, I'll give an example:
I have an exe file on drive D:\ which I run (with previously posted question's answer, giving params to "Start in" folder on C:\Program Files\MyProgram\" so it finds its dlls.
Now after the file is running, I'd like to rewrite the file's byte stream (just like opening it in hex editor...), or at least delete it so I can copy over new exe file directly using same name.
So far the solution I'm using is that I trigger format D: command for the whole drive D:\ (which, in my case is ramdisk and thumb-drive, as I only have this exe on it, I copy it there as necessary), since that removes the file and let's me copy new file there.
Trying to use del myProgram.exe even with -force flag triggers error that access to the file is denied. Same goes if I try to overwrite the contents of the file.
Is there any alternative to do that without using the format command, as that requires to have partition drive only for the purpose?
Update: Note: MoveFileEx and similar techniques that require termination of the process or system restart/reboot are not qualified as a solution. This should be done while the process is running without further actions that can compromise the process's run state.
On a side note, when formatting the drive using the Powershell's format command, the file is gone, although if viewing the partition using Hex viewer tool, there is full binary (hex) content of the exe visible there and an be restored using just as simple as copy-paste technique. This is one of the points as to where overwriting the file contents would be preferable than deleting the file directly.
Please note: This is a knowledge and skills based question, and would therefore appreciate sparing the moral and security-concerning comments about such actions and behaviour.
For deleting/replacing/overwriting a file at least two conditions must be met:
The user performing the operation must have the required permissions to do so. This can be verified for instance via Get-Acl or icacls.
Windows must not have an open handle to the file. This can be checked for instance with tools like Process Explorer or handle. These tools can also be used to forcibly close open handles, although that's not recommended as it may cause data loss and/or damage to the files in question. I'm not sure, though, if it's actually possible to close handles to an executable without terminating the process.
Note that antivirus software is likely to interfere with this kind of operation.
The basic problem here is that Windows loads from the .EXE upon demand, it's not all read in at once.
If you destroy the original file what happens when it tries to load in a page that no longer exists?
If I had to write something of this sort I would copy the .exe to a temporary location (beware that running code from the temp directory may be prohibited), run the new .exe, terminate the old one and then do what I want to it.

Custom batch file creation for building code generated from Simulink Models

How can I create a custom batch file for my code generated from Simulink model ?
I can see, if I edit and change my template make file from Configuration Parameter Dialog box, I can get the desired make file.
But I want a custom .bat file too, that calls this make file along with other commands.
I have some environment variable to set and run couple of scripts in .bat file, before compilation begins. Based on these outputs from script the code is to be compiled and linked.
Using Matlab Version: 2012b
Create a STF_wrap_make_cmd_hook that generates your desired modelname.bat file as shown in the example code
here (mathworks login necessary).
You will probably also need to write your own make_yourtarget.m file and edit the make command field shown in your screenshot to use that one instead of make_rtw.
Other hooks into the build process are described here, perhaps the 'before_make' will also be useful.