• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: System command executed from QT does not work for service

Resolved: System command executed from QT does not work for service

0
By Isaac Tonny on 16/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve System command executed from QT does not work for service

Question:

Why does the service not get restarted?
  • For an innocent command, things work well. nmcli networking connectivity gives full
  • echo 'pwdthatshouldbeavoidedIknow' | sudo -S -n systemctl restart rtunnel.service works when executed as the same user that executes the program in a terminal.
  • Other sudo commands work too in the same program e.g.

Best Answer:

You can not use Pipes in QProcess.start(). After some testing I found out that sudo doesn’t work as expected when not called from a command line interpreter.
Start a bash and write your commands to it. Remember to exit the bash! Note that the newline characters in the write‘s are important!
Note: The -S parameter in sudo is used to read the password from standard input instead of from the terminal.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

c++ linux qt ubuntu
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How can I write CSS selector(s) that apply to table rows for all td elements on that row after a td with a certain class?

01/04/2023

Resolved: How do I use SetWindowText with Unicode in Win32 using PowerShell?

01/04/2023

Resolved: Shopware 400 Status Error “This value is too long. It should have 255 character or less.” When I Try Updating Database Table

01/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.