I have written a program in C++ to read the processes from a file into a vector and then to execute the processes line by line.
I would like to find out which processes are running and which aren't by using proc in c++
Thanks.
My code:
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <cstdlib>
using namespace std;
int main()
{ int i,j;
std::string line_;
std::vector<std::string> process;
ifstream file_("process.sh");
if(file_.is_open())
{
while(getline(file_,line_))
{
process.push_back(line_);
}
file_.close();
}
else{
std::cout<<"failed to open"<< "\n";
}
for (std::vector<string>::const_iterator i = process.begin(); i != process.end(); ++i)
{
std::cout << *i << ' ';
std::cout << "\n";
}
for (unsigned j=0; j<process.size(); ++j)
{
string system=("*process[j]");
std::string temp;
temp = process[j];
std::system(temp.c_str());
std::cout << " ";
}
std::cin.get();
return 0;
}