So I have
if (WEXITSTATUS(system("gksudo")) >= 1)
cout << "Accept"
else
cout << "Denied"
Am I right???
So I have
if (WEXITSTATUS(system("gksudo")) >= 1)
cout << "Accept"
else
cout << "Denied"
Am I right???
Precisely backwards. Nonzero values mean error. You can simplify the expression a lot:
if(WEXITSTATUS(system("gksudo")))
cout << "Error\n";
else
cout << "Success\n";
Ok, thank you so much!!!
I'll try this in a moment and i'll let you know!
---------- Post updated at 02:25 AM ---------- Previous update was at 02:20 AM ----------
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
if(WEXITSTATUS(system("gksudo")))
cout << "Error\n";
else
cout << "Success\n";
return 0;
}
Error at line 10: if(WEXITSTATUS(system("gksudo"))) --> lvalue required as unary �&� operand
---------- Post updated at 05:51 AM ---------- Previous update was at 02:25 AM ----------
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
int lol = system("sudo -i");
int exitstatus = WEXITSTATUS(lol);
if(exitstatus)
cout << "Error\n";
else
cout << "Success\n";
return 0;
}
This works fine. Thanks.
What is gksudo?
Gksudo does exactly what sudo does but it pop-ups a nice prompt. The same prompts that pop-ups when you open synaptic package manager in 10.04