Results 1 to 5 of 5
Hi all,
I am new to Linux and Qt programming and c++.
My question is how to start a process for example the msqld server? I can do that from ...
- 09-11-2008 #1Just Joined!
- Join Date
- Sep 2007
- Posts
- 33
start the mysql service and run commands
Hi all,
I am new to Linux and Qt programming and c++.
My question is how to start a process for example the msqld server? I can do that from the command line typing :/etc/init.d/mysqld start. But how can my programm do that? I need to run this command as a super user from my program.
How can detect the status of this process before opening it? Like in command line we do :/etc/init.d/mysqld status.
I made a small code trying to start the mysql server but it doesnt work. I think because i dont run the command as a super user. How can i modify that so it can start the process?
Code:#include "kentriko.h" #include <iostream> using namespace std; kentriko::kentriko(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); connect(ui.anixe, SIGNAL(clicked()) , this , SLOT(anixe())); connect(ui.pare, SIGNAL(clicked()) , this , SLOT(pare())); connect (ui.xekina,SIGNAL(clicked()),this,SLOT(xekina())); connect (ui.stamata,SIGNAL(clicked()),this,SLOT(stamata())); connect (ui.dixe,SIGNAL(clicked()),this,SLOT(dixe())); } void kentriko::anixe(){ d.exec(); } void kentriko::pare(){ //ui.pare_1->text("ena") ; den kano sosti xrisi tis text() ui.pires->setText(d.get_alpha()->pliroforia); } void kentriko::xekina(){ process.start("/etc/init.d/mysqld start"); } void kentriko::dixe(){ ui.dixe_l->setText(process.readAllStandardOutput()); } void kentriko::stamata(){ process.execute("/etc/init.d/mysqld stop"); ui.dixe_l->setText(process.readAllStandardError()); } kentriko::~kentriko() { }
Many thanks in advance,
Kindest regards.
- 09-11-2008 #2Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
1. install sudoers
2. add this line to /etc/sudoers
intended_user ALL=NOPASSWD:/etc/init.d/mysqld
3. add the above user to mysql group
4. command to run:
sudo /etc/init.d/mysqld status
(replace intended_user with the user that will run the command)
- 09-11-2008 #3Just Joined!
- Join Date
- Sep 2007
- Posts
- 33
any other way?
Is there any other way without the sudo command?
Thanks
- 09-11-2008 #4
try this web site...it will explain and show you how to create a user program with super user privileges
Users and Groups - The GNU C Library
- 09-13-2008 #5Just Joined!
- Join Date
- Sep 2007
- Posts
- 33
Thank you
Many thanks for that


Reply With Quote