Using exec system call list all the files and directories of home then
store the result in “output1.txt”. Run a second command “grep” and find
the word “output1.txt” in all the text files of the home also place the home
path in the “PATH” environment variable while doing exec for grep. This all
will be done in one process.
if (fs.peek() == EOF)
{
cout << "File BD empty" << endl;
BackEvent(enter3, logos, ftr, colorF, colorW);
cin >> enter1;
fs.close();
}
else
{
while (!fs.eof())
{
data[i] = (char*)malloc(sizeof(char) * size);
fs >> data[i] >> ch;
if (i > 0)
{
ster = ch + data[i];
data[i] = ster;
}
ce = ch;
cout << data[i] << "\0" << endl;
i++;
if (i > 0)
{
data.push_back("");
}
}
cin >> loaddata;
fe.open(data[loaddata]);
while (fe.peek() == EOF)
{
cout << "File " << data[i] << "empty or does not exist!" << endl;
BackEvent(enter3, logos, ftr, colorF, colorW);
cin >> enter1;
}
while (!fe.eof())
{
msg = "";
getline(fe, msg);
cout << msg << endl;
}
Comments
Leave a comment