I want to restart my computer by running a command in linux using QProcess . I have a hard password of my root in my application.
When I run the following in the terminal, it works fine:
echo myPass | sudo -S shutdown -r now
When I put the command in a shell script and QProcess it through QProcess , it is also successful:
QProcess process; process.startDetached("/bin/sh", QStringList()<< "myScript.sh");
But I can not start it by going directly to QProcess :
process.startDetached("echo myPass | sudo -S shutdown -r now ");
It just prints myPass | sudo -S shutdown -r now myPass | sudo -S shutdown -r now
How can you run such relatively complex commands directly using QProcess . (Do not put shell script).
c ++ linux shell qt qprocess
Nejat
source share