4

Most of the time running a gtk application from the command line it starts dumping debug information to the stdout even though I put them in background.

Example:

~$ gedit test.html # and ctrl+z to suspend
zsh: suspended  gedit .zshrc
~$ bg
[1]  + continued  gedit .zshrc
~$
# do some editing
(gedit:6208): GtkSourceView-WARNING **: Could not find word to remove in buffer (whoosh), this should not happen!

(gedit:6208): GtkSourceView-WARNING **: Could not find word to remove in buffer (haystack), this should not happen!

I want to note that the error, or warning, changes according to what I'm doing at the moment. The GtkSourceView-WARNING shown here is one of the cases.

Anyway... Do you know if it's at all possible to avoid getting that information printed out?

tutuca
  • 2,682
  • Is it a bug that this info creeps out to the stdout even though I'm bging the process? – tutuca Mar 22 '12 at 13:52
  • I'm not acquainted with zsh, but I don't think so. Bash does the same thing. – zpletan Mar 26 '12 at 03:42
  • I didn't meant a bug in zsh... I mean a general bug in any application to print debug information in stdout .... Too much confusion in this question, I will vote for closing. – tutuca Mar 26 '12 at 16:08
  • 2
    Don't close it; if you think it's too confusing, edit it so it's not. Personally, I think it's a great question, and in the question body, I only see one question anyway. – zpletan Mar 26 '12 at 16:11
  • I would think piping it to grep with some arbitrary words after would work too.

    i.e. gedit | grep 'jkhcjbibijy1987189 jc1_12'

    – No Time May 15 '14 at 03:46

3 Answers3

8

You can send those standard output and error messages to the null device, so that they don't show up in your terminal, e.g. gedit test.html >/dev/null 2>&1

blee
  • 559
  • 2
  • 5
  • 17
-1

Another way to do it would be to start the command as a background process and then detach it from the current shell. This will 'hide' all output in the sense that the current shell is no longer interested in the process. The syntax in bash is:

gedit test.html &
disown %1

I often use the output redirection mentioned in the other answer because it is very flexible. You can output to files, devices, connect outputs, etc. However this is useful for when you have no interest in the output, you just want to start a GUI application from a shell and then have no other interaction with it.

Huckle
  • 7,188
-1

I don't know if this is exactly what you're looking for and if it'll help you, but:

Since you're saying that you want to run a GTK application in the background, you could do this:

nohup <applicationname> > /dev/null < /dev/null &

The nohup programm basically detaches the application passed to it from your terminal, allowing the terminal session to end, but with the application can still running.

You can close the terminal, or continue to use it (since all output is sent to /dev/null) without issues, because of the & command. A nice simple explanation for it can be seen here.

AeroCross
  • 153
  • I know how to send apps to the background. What I want to avoid is the debug information getting printed. It happens with a lot of applications. – tutuca Mar 24 '12 at 01:25
  • Did you try the command? Because `> /dev/null < /dev/null does what you want (or at least, for me it does) – AeroCross Mar 24 '12 at 05:26
  • What's the point of < /dev/null? nohup already combines stderr and stdout so > /dev/null will silence all warnings. </dev/null reads from /dev/null and there's not point to that as far as I can tell. – terdon May 14 '14 at 16:57