QProcess unable to start shell commands linux
I would like to execute shell commands using QProcess,i have searched forum and read documentation but i can't solve my problem.
For example,
cmdline="/bin/bash";
arguments << "-c" << "sudo apt-get install";
process->start(cmdline,arguments,QIODevice::ReadWrite);
The result of above program is:
sudo: no tty present and no askpass program specified
If the arguments are:
arguments << "-c" << "ls -l";
then the function is executed correctly.
i have edited sudoers file using visudo in order not to ask password for a specific user.
Thanks!
Re: QProcess unable to start shell commands linux
The problem is obviously with sudo and not with Qt.
[SOLVED]: QProcess unable to start shell commands linux
As wysota wrote, the problem was with sudo. (The command was not executing due to editting sudoers file).
If someone else has similar problem the following code works:
QString apath,program;
QStringList args;
apath=QDir("/bin/bash").absolutePath());
program="gksudo";
args << "apt-get install";
process->start(program,args);