As a small project i am testing the use of mac terminal commands with C++, I
have started with the basic ones (ps aux, telnet etc, etc). I was wondering if there was any way to include a user input in the command sent to the terminal , eg entering the PID of the program you want to kill. Just in case it helps the code i am using is posted below.
have started with the basic ones (ps aux, telnet etc, etc). I was wondering if there was any way to include a user input in the command sent to the terminal , eg entering the PID of the program you want to kill. Just in case it helps the code i am using is posted below.
Code:
#include <iostream>
int main()
{
int proc;
int PID;
using namespace std;
cout << "Welcome to the terminal tool for the common idiot\n";
cout << "Please choose from the below options, which process you would like to perform";
while(1)
{
cout << "(1) Show all running process's, (2) Telnet options, (3) Send Mail, (4) Kill application\n";
cin >> proc;
if (proc==1)
{
system ("ps aux");
}
if (proc==2)
{
system ("telnet");
}
if (proc==3)
{
system ("MAIL TO:");
}
if (proc==4)
{
cout << "Enter PID (obtained via process 1)\n";
system ("kill") ;
}
else
{
cout << "that is not a valid response, please select an option from the menu\n";
}
}
}