Evasive comments
On this question the OP is evading answering if he's using Ubuntu or not. The question's comments illustrate this:
You should include the "#some gksudo related output" because on my system there are no error messages. What version of Ubuntu are you using? : WinEunuuchs2Unix
The warnings are related to the gtk theme, however, is not really important what the errors are as I just want to hide the output, not fix the warnings : angrykoala
I get warnings related to gtk theme all the time when running
gedit
which I suppress programmatically so I totally understand your annoyance at them. My point is there are no errors withwhoami
on my system which makes me concerned about your system. I triedgksudo
,gksu
andpkexec
all of them have no errors. : WinEunuuchs2Unixwhoami is just an example as well, it could be any other command, which I want to get the output, including errors : angrykoala
I understand. I'm just trying to duplicate the problem on my side. Are you using Ubuntu? In the mean time look at: askubuntu.com/questions/896935/… and: askubuntu.com/questions/505594/… as possible duplicates. : WinEunuuchs2Unix
This is for a script, so I would rather get a programmatic solution to avoid the output on any system. Instead of whoami, any command that send stderr would be valid to recreate the problem : angrykoala
Background
OP claims this happens on his system:
$ gksudo whoami
> #some gksudo related output
> root
But on my Ubuntu 16.04 with a brand new terminal no such messages:
rick@dell:~$ gksudo whoami
root
rick@dell:~$ gksu whoami
root
rick@dell:~$ pkexec whoami
root
So either he isn't on Ubuntu 16.04, or my version of terminal is corrupted or he isn't using Ubuntu at all. Which makes helping him difficult in this case as the problem isn't reproducible.
gksu
/gksudo
are deprecated and should not be used any longer anyway, because you should not run any GUI stuff as root at all. If he wants to launch some CLI commands in a script and wants a GUI popup asking for the password just for not needing to have a terminal open, that could also easily be crafted e.g. with Zenity, which comes preinstalled.gksu
does not.whoami
doesn't issue GTK warnings. Which I already knew as it's not a gtk based program. It leaves me scratching my head what kind of system he is running. A GTK based terminal or something????gksudo
's popup window, which could be GTK based... But I have no idea. No messages for me here either. Or he's simply using a different command and not admitting it.gksu
was being deprecated which is why I started switching scripts over topkexec
a few months ago. But the OP's question was aboutgksudo
and I'm trying to figure out if the reason mine is different than his is because he's not on Ubuntu. Which makes it impossible to help him.gksudo whoami
. That's three of us now so I think we can confirm he's not on Ubuntu???&1>2
(or whatever) and other techniques for suppressing messages. I just have a bad feeling about this whole issue...