Using linux commands in C++
How do i use/call the linux command
hdparm -i /dev/hda in/through a C++ program? thanks |
You can try the system command from <cstdlib>.
See here details. Quote:
|
#include <stdlib.h>
#include <iostream> #include <stdio.h> int main() { system("hdparm -i /dev/hda | grep -i serial"); } i wrote the following code and it gives the output as: [root@localhost anuradha]# ./hddid Model=SAMSUNG SP0802N, FwRev=TK200-04, SerialNo=S00JJ20X897934 [root@localhost anuradha]# what i need is.. i should be able to use the output further in my code... so i dont have any handle or variable where this output is stored.. so that i can use it further.. |
Quote:
Popen will allow you to read output of executed program. Just don't forget when you done with reading use pclose |
Quote:
Like, I had to check whether I am connected to other box or not. I found ping to be an easy way to check the connection. If Quote:
I did the following Quote:
Quote:
Admittedly, this is not a proper or an ingenious way :) Perhaps, gurus at LQ will share a proper method. |
All times are GMT -5. The time now is 08:12 PM. |