How to use cppcheck command the input path from txt file - cppcheck

I'm using Cppchek to analyse my source codes
By this command : cppcheck inputPath1 inputPath2 --enable=warning --xml 2> cppcheck-result.xml the report was well generated, However, I require a method to store the inputPath in a text file so that it can be read by the command line that will be executed.

Related

how to exclude multiple files using cppcheck with command line

I'm using cppcheck to analyse C source code
Using this command : cppcheck --enable=warning inputpath1 inputpath2 inputpath3 -iexcludepath1 excludepath2 --xml -U_DEBUG 2> .\CppCheckReport.xml
I'm able to generate an XMl report which contains the analyse results of the three input files with the exclusion of the exclude file1 only.
I need to exclude the two files using the -i option one time that's mean that I don't want to use this command : cppcheck --enable=warning inputpath1 inputpath2 inputpath3 -iexcludepath1 -iexcludepath2 --xml -U_DEBUG 2> .\CppCheckReport.xml
Is there any other method to exclude multiple files using cppcheck command ?

How do we compile and run a program on the CS50 ide?

So basically I am a starter in programming. I do not understand how do I compile and run the program below on Harvard's CS50 IDE.
#include<iostream>
using namespace std;
int main()
{
cout<<"HelloCS50";
}
enter image description here
Start typing in the terminal. follow each command you type with the enter key.
Use the command ls to list all the files in your directory. One of those files should be the code you just wrote and saved.
It's not a requirement, but will make it easier to have the filename end in '.cpp'. If your file does not have that, you can save the file again and add '.cpp' to the filename.
Assuming that your filename is "hello.cpp", use the command g++ hello.cpp to compile your code. This will create another file called a.out.
You can now run your code with the command ./a.out. After doing this you should see that "HelloCS50" has been printed onto the screen.
1: save your file name with .cpp extension. If your file does not have that, you can save the file again and add '.cpp' to the filename.
2: Consider that your filename is "hello.cpp", use the command make hello to compile your code. This will create another file called hello.
3: Now you can write your code with the commond ./hello. After doing this you should see the Output.

Trying to compile a cpp file but command prompt saying file not found

I have downloaded the c++ compiler from MinGW also set the environment variables
'<' and '>' are research characters for redirection and are not to be used in file names.
most likely in this case it is trying to read input from hello_world as it would be seeing < hello_world but not find the file
The > p.cpp would be attempting to write any output to p.cpp, so may have replaced what you had in that file.

Executing a batch file containing an exe path remotely via wmic

I have a batch file on Computer-A that contains several commands and a path to an exe file.
When I execute the batch file on Computer-B via wmic, I can see all the commands being executed in the batch file except that it does not run the exe. What are the things I need to check for to see why the .exe is not being executed on Computer-A?
wmic execution:
wmic /node:"<server_ip>" /user:domain\user /PASSWORD:"password" /OUTPUT:STDOUT process call create "cmd.exe /c C:\Folder\batch.bat"
File paths in wmic need to be c style paths. So C:\\somefolder\\somefile.ext. \\ for\ in paths.

compiled fortran code looks for input parameter file in the incorrect directory

I have a compiled fortran 90 code "NewSourceID.exe"in folder E:\TROUBLESHOOT. This uses input file MAIN.IN in the same folder. I use a batch script run_sa.BAT in the same folder E:\TROUBLESHOOT to run this executable. This batch script is generated at run time by another VB code (this is a requirement and cannot be done away with) and the batch script reads as following.
"E:\TROUBLESHOOT\NewSourceID.exe" "E:\TROUBLESHOOT\MAIN.IN".
There are two scenarios
1. When I go to the folder E:\TROUBLESHOOT and double click the batch script run_sa.BAT the NewSourceID.exe runs correctly without any problem. It runs on the command prompt window showing the path C:\WINDOWS\system32\command.exe.
When I run the same from the VB script by generating the batch script at runtime I get the following error.
"
C:\Documents and Settings\epsuser\My Documents>"E:\TROUBLESHOOT\NewSourceID.exe"
"E:\TROUBLESHOOT\MAIN.IN"
forrtl: severe (29): file not found, unit 31, file C:\Documents and Settings\eps
user\My Documents\MAIN.IN
The code tries to find the input file MAIN.IN on the path C:\Documents and Settings\epsuser\My Documents\MAIN.IN which is not the correct path to look for the file.
This happened when I replaced the NewSourceID.exe with a modified one. Earlier the code used to run correctly even from the VB with the following path. C:\WINDOWS\system32\command.exe -E:\TROUBLESHOOT\run_sa.BAT. How can this be done?
Are you sure, the Fortran program NewSourceID reads the command line argument you pass to it? Especially older Fortran programs (before Fortran 2003) had no standard way to parse command line arguments. I guess, the name MAIN.IN is hardwired in the code you use, and it always uses the MAIN.IN file from the current directory. You could work around this by issuing a change directory command before executing the program. I am not very familiar with Windows, but something like
cd E:\TROUBLESHOOT
E:\TROUBLESHOOT\NewSourceID.exe
in your batch script would probably work.
Alternatively, you could implement proper command line argument parsing in your Fortran code, using the command_argument_count() and get_command_argument() functions. You would need a Fortran 2003 compiler for that.