Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Writing command to Terminal in Qt
is it possible to write a command to Terminal in Qt without opening a the Terminal window?
QProcess comes to mind for that kind of task
@SGaist I have been looking in forums and everytime someone uses the QProcess they use
and this causes for the Terminal to open.
If you take a look at QProcess's documentation, you'll see an example with gzip.
What command do you want to run ?
checking if a user in Linux has sudo privilages
@SGaist So on the GUI, there is going to be a username and password LineEdits and when the Ok button is clicked, I want it to run the following command without the Terminal window opening in order to check:
$ su - username
if password is not correct
if username does not exist
if user does not have sudo privileges
IIRC you can't pass a password to su
@SGaist What I was thinking of doing was for Qt to write the command su -username. Waits for the Terminal to process that. Then the terminal will output that it is asking for the password and so Qt will write the password. Is that possible
But you don't want Terminal to show its face. So yes you can to it with QProcess but again and AFAIK su requires a real terminal to input the password. IIRC sudo would be simpler to use in that case.