Unsolved Writing command to Terminal in Qt
-
is it possible to write a command to Terminal in Qt without opening a the Terminal window?
-
Hi,
QProcess comes to mind for that kind of task
-
@SGaist I have been looking in forums and everytime someone uses the QProcess they use
process->start("xterm");
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 ?
-
@SGaist
checking if a user in Linux has sudo privilages -
So calling
sudo -v
? -
@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
Password: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.