How to use wmi in Ubuntu with C++ - c++

I want to get information from my Client's that running Windows through Linux.
I have several clients that running Windows, and I'm running Ubuntu. I want to make a C++ code, and get information like CPU usage, disk space, etc from my client's.
Is there any way to do that?
I know I can use WMIC (WMI Client) and execute query (WQL) from terminal, but I want to use some libraries in C++ (I use Qt Creator).

First Create an application using the following library
http://msdn.microsoft.com/en-us/library/aa390423(v=vs.85).aspx
and send this information back to the ubuntu either using sockets or any other ports or simply save it into a txt file and access that file using ftp.
http://msdn.microsoft.com/en-us/library/aa394558(v=vs.85).aspx
Is there any C++ library to work with WMI?

Related

Qt C++ application: self autostart installation in Linux

I'm porting some Qt Windows/VC++ code to Linux/GCC. The application can add it's own shortcut to the Windows Autostart folder so the application starts after login.
I want to do the same in Linux. I'm using Kubuntu 15.10 but the solution should work for virtually all (or at least most) Linux variants out there. And it should work without super user rights (or it should request the rights automatically).
I searched the web and found two solutions:
Add a desktop entry file to $HOME/.config/autostart
Add a symbolic link to /etc/init.d/
Will they both work in all Linux distributions? What are the differences? Which is to be preferred?
Also I would like to know if I should do that by programmatically running a shell command or if there is some native API I could use in C/C++ (including easy error detection).
I have put project in GitHub for managing auto-start feature in different OS. It's written in Qt.
Please check it and let me know if you have any problem using it:
https://github.com/b00f/qautostart
You can add application in various ways.
Via linux init system. For newest linux OS systemd is a standard. In this case your need to create systemd unit for your application
Via desktop manager, such as gnome, kde and possible others. In this case you need also create specification for autostarting your app.
Via bash files
I think, prefered way via systemd unit, because now this is standard way for starting process at boot time and for special user, if need.

IAR Embedded Workbench: Exporting data from Terminal I/O

I'm currently working on a project in IAR Embedded Workbench, and I've run into a problem that I can't seem to figure out.
I have written a program that interacts with hardware to get information from the board to perform calculations. The calculations are correct, and are being printed out to the Terminal I/O from the program.
I would like to know if it's possible to access these calculations for use in a third-party program.
We are expanding on a previous project which utilized additional hardware to send the information to a third-party program, but at this stage, it's not exactly an option.
Does IAR Embedded Workbench store this information somewhere, or are there settings I can reconfigure to allow for exporting data?
If you use the full DLIB library, and you run the application in the C-SPY debugger, you can use 'fopen', 'fprintf' and friends to write to a file on the host machine.
This work both when using the IDE or when running in batch mode using 'cspybat'.

Can an IDE/Netbeans connect to a remote computer and compile/run/debug code on it?

I'm developing a program for a specific environment. That means it needs to run on the OS and compile using its compiler. I have a different environment at home (Windows 8) is there a way Netbeans can be used to connect to the target environment and use its compiler? It is enabled for remote login.
So basically right now I write code on my home computer, connect using Putty to the target computer, copy the source code over, compile it and run it. I'm trying to simplyfy this process so I only have to use Netbeans.
Why don't I just get same compiler and do everything locally? The target computer is running Linux and the program has a lot of system calls.
I know Aptana has a simillar feature, but Aptana is so crappy in general I don't want to use it.
Let me know if my question doesn't make sense and I'll try and reword it.
Yes, you can do remote development in NetBeans. It's described in its Help subsystem:

How to debug a linux C++ program from Windows with Eclipse?

I use a headless (i.e. no screen) remote ubuntu server x64 for developping a C++ application (with no UI either).
I want to conveniently (IDE like, not command line) debug this program from windows (7/64), with Eclipse if possible. I have a windows share between the two and full root access on both machines.
So far I have heard of two solutions :
Remote gdb
Remote X server
I have worked on solution 1 : built a cross gdb, copied my program and libs on windows. I'm able to remote-gdb from cygwin command line, but not from eclipse (stuck at "launching... 85%" with no error message nor log)
I have also worked on solution 2 : installed xauth, set X forwarding, installed xming on my windows, set DISPLAY on the linux box. But no effect "can't open DISPLAY xxx" with no easy troubleshoot.
When googling for those problems, I only find outdated pages or different problems.
Did anyone do it ? Can you share advices or fresh pointers on how to remote debug a C++ linux app from Windows ?
I suggest to install an X11 server on your Windows machine (e.g. Xming perhaps?) and to do ssh -X with some X11 client applications (like emacs, ddd if needed, xterm) on your Linux server. Don't use a complex thing like Eclipse. You could just use emacs (remotely on the Linux server, displaying on the Windows desktop X11 server)...
Once emacs works well (running on the remote Linux server, displaying on the Windows desktop X11 server), you can run gdb inside it.
To get ssh -X working, you need to configure it appropriately. Maybe you forgot that step. To test it, just use ssh -X yourlinuxhost xterm, and work on configuration till that step works.
Of course you could also install Linux on your laptop or desktop, perhaps inside a virtual machine above your Windows.
NB. I never used Windows, but I do know that some X11 servers exist for it.
There is a eclipse plugin RSE (Remote System Explorer), it can pretty much do what you are expecting. The code base can be in linux server, eclipses uses telnet / ssh to login. Execution again can happen on a server, native gdb is used to debug.
You can use the following simple plugin for Eclipse.
http://marketplace.eclipse.org/content/direct-remote-c-debugging
It needs just ssh connection to the server and it cares about anything else

program doesn't work after FTP

I was working on a c++ project on a remote linux server via ssh. I decided I wanted to test the files on my own machine using valgrind. I FTP-ed the project directory from the remote server to my own machine, compiled, and attempted to run.
I got the message:
Error opening /proc/96855/stat
And based on the different arguments I ran my program with, that number between proc and stat would change.
Does anyone know what happened here? Shouldn't everything work just fine on my machine as long as I have all the .cpp and .h files necessary? It compiled just fine, so I am lost.
What operating system is your local machine running?
My guess is that it doesn't support operations that the software requires (for example, trying to access processes through the /proc directory).
Maybe you forgot to tell FTP that this was an "image". Try again with "image" turned on.
Another practice that I use when I FTP is to turn on hashing with "#". I want to be able to see that the number of bytes transferred is exactly the same as the size on my machine.
Maybe a client program like FileZilla would help as well.