You can also use the LaunchCommand function in Bazaar/SysInfo package Smile
String LaunchCommand(const char *cmd)
where cmd is just the command line string. It returns the command output.
It is documented and if you see the code in the same SysInfo.cpp you will see many examples of its use.
This function does work for Windows and Linux. The exception is in basic OS commands in Windows like "dir" and "copy". If you want them to work out of a command line and hidden it will be needed something different.
It is not usually necessary as this commands are so basic that their functionality is included in libraries (list files in folder, copy files, ...).
TeCNoYoTTa Messages: 138 Registered: July 2008 Location: Egypt
Experienced Member
I downloaded the latest version of U++ but i get this error :S :S
when compiling sysinfo
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:11:21: error: rpcsal.h: No such file or directory
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:12:21: error: Wbemidl.h: No such file or directory
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:2267:1: error: unterminated #if
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp: In function 'bool GetWMIInfo(Upp::String, Upp::Array<Upp::String>&, Upp::Array<Upp::Value>**)':
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:493: error: 'IWbemLocator' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:493: error: 'pIWbemLocator' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:494: error: 'CLSID_WbemAdministrativeLocator' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:501: error: 'IWbemServices' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:501: error: 'pWbemServices' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:518: error: 'IEnumWbemClassObject' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:518: error: 'pEnumerator' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:525: error: 'WBEM_FLAG_RETURN_IMMEDIATELY' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:535: error: 'IWbemClassObject' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:535: error: 'pClassObject' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:539: error: 'WBEM_INFINITE' was not declared in this scope
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp: In function 'bool TakeWindowPlacement(HWND__*, RECT&, POINT&, POINT&, long int&)':
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:2345: error: 'struct WINDOWPLACEMENT' has no member named 'show'
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:2345: error: expected `;' at end of input
D:\Program Files\U++\bazaar\SysInfo\SysInfo.cpp:2345: error: expected `}' at end of input
You are right. The implementation of LaunchCommand in SysInfo is like yours just using LocalProcess instead of One<SlaveProcess>.
Just in case, SysInfo is complete for Linux and Windows with MSC.
However with MinGW you have to add these files from the MSC install or from other sources:
To Upp\MinGW\include:
- Files Rpcsal.h, DispEx.h, WbemCli.h, WbemDisp.h, Wbemidl.h, WbemProv.h and WbemTran.h
- They can be taken from: \Microsoft SDKs\Windows\v6.1\Include
To Upp\MinGW\lib:
- File wbemuuid.lib
- It can be taken from \Microsoft SDKs\Windows\v6.1\Lib
In the usvn package, there is the SysConsole class. You might want to check it.
It is sort of waiting for being moved to CtrlLib or something like that, after perhaps some refurbishing. Maybe you can try it out of usvn context to check what is missing for general use?
In the usvn package, there is the SysConsole class. You might want to check it.
It is sort of waiting for being moved to CtrlLib or something like that, after perhaps some refurbishing. Maybe you can try it out of usvn context to check what is missing for general use?
I have tested it and I find it useful. In fact I have a class with the same functionality...
Please move it to the main library
I will substitute my class with yours to see if anything else could be necessary.
One thing I would do now is to manage '\r':
Some programs as mencoder or ffmpeg show in a line the status of the process, printing lines one over other
For TeCNoYoTTa: You do not need ExecuteCMD
... as Sys() function just does the same:
int Sys(const char *cmd, String& out)
{
out.Clear();
LocalProcess p;
if(!p.Start(cmd))
return -1;
while(p.IsRunning()) {
out.Cat(p.Get());
Sleep(1); // p.Wait would be much better here!
}
out.Cat(p.Get());
return p.GetExitCode();
}
For Mirek and everybody: To organize us a little
I know it is not the first time I tell it, I see many times that different people do the same thing.
It would be great to have a place to put the "THINGS TO DO" so people that have time can take them and do it. If somebody has not time to follow can ask for help and other people can "pass the baton on to the next relay runner".
We had three implementations of Sys(), now we have two implementations of cryptography.
The reason I announce the things I will do months before is just to coordinate with others, but it is not the best way.
Mirek: Thank you for having Bazaar inside Upp. Other projects do not have the same.
However perhaps it is the time to have some kind of better Bazaar inside or outside Upp web page:
- With a project list with description: All the Bazaar packages visible
- With all documentation: Now Bazaar documentation is not in the web page
- With a TO DO board to organize the next things to do. For Bazaar and Upp main packages
Would be nice to have a page where are listed all Bazaar packages, their author and a short description and also the projects which someone is doing and will be in bazaar when they are finished so we remove duplicate efforts as you explained with SysExec/SysConsole/ExecuteCMD etc.