LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problem in launching a terminal command with a Qt Button (https://www.linuxquestions.org/questions/programming-9/problem-in-launching-a-terminal-command-with-a-qt-button-787946/)

hdinn 02-09-2010 03:10 AM

Problem in launching a terminal command with a Qt Button
 
hello everybody,

I've created a QT interface with some buttons and labels, and i want to launch a terminal command with one of these buttons,but the command maust starts with "sudo",unfortunately it didn't work because it wants root password and i can't enter it even in the Button cammand....

plz help mz

thnx

Aquarius_Girl 02-09-2010 10:18 PM

Did you try asking this question on their mailing list ?

http://lists.trolltech.com/mailman/listinfo/qt-interest

evo2 02-09-2010 10:38 PM

You could use one of the gui frontends to sudo. Unfortunately the only ones I know of are:

- gksudo - maybe not good for you since you are using qt, not gtk
- kdesudo - qt, but maybe not good for you since it depends on kde libs

Evo2.

graemef 02-09-2010 10:58 PM

This is not really a QT problem, but how the script that you are trying to run works. Possibly a work around is to write a wrapper script which will receive a password and then call the script that you want to run, avoiding the interactive demands of sudo. If you gave some more information I might be able to give you a better answer. What does the script you want to run do, why do you need to use sudo?

hdinn 02-10-2010 02:25 AM

Quote:

Originally Posted by graemef (Post 3858579)
This is not really a QT problem, but how the script that you are trying to run works. Possibly a work around is to write a wrapper script which will receive a password and then call the script that you want to run, avoiding the interactive demands of sudo. If you gave some more information I might be able to give you a better answer. What does the script you want to run do, why do you need to use sudo?



thank you for your reply,actually i want to run an IPTABLES command which needs "sudo" as prefix,in terminal i write
Code:

sudo ./my prog
and the button command runs correctly however without "sudo" when i click on the button it gave me "Permission denied you must be root", and when i write
Code:

sudo iptables ------
in the button code it gave me you didn't write the root password.

i hope you understand now my problem :scratch:

graemef 02-10-2010 06:03 AM

Flicking through the man pages for sudo. It looks that you can use the -A option to get a GUI to capture and then return the password to sudo, this is not something that I have done the man pages says that you will need to set up the SUDO_ASKPASS setting but that may be worth playing around with.

nowonmai 02-10-2010 08:50 AM

Edit /etc/sudoers to contain something like...

Code:

        hdinn    ALL = NOPASSWD: /path/to/myprog


All times are GMT -5. The time now is 03:44 AM.