4

Need to have the process of command typically an update to be shown using yad and at the same time log all the output to a given log file set up. This is what I have

apt-get update | yad --width=400 --height=300 \
--title="Updating debian package list ..." --progress \
--pulsate --text="Updating debian package list ..." \
--auto-kill --auto-close \
--percentage=10 

The above command creates a pulsating indicator for the process and closes on finish but I need to have it log all the output it gives I have tried

apt-get update >>${logfile} 2>&1 | yad --width=400 --height=300 \
--title="Updating debian package list ..." --progress \
--pulsate --text="Updating debian package list ..." \
--auto-kill --auto-close \
--percentage=10 

but that gives me an error and hangs from there on no dialog and no logging just freezing. Here is the error

 GLib-CRITICAL **: g_source_remove: assertion `tag > 0' failed

Help appreciated

  • Did you try with tee? apt-get update | tee logfile | yad [...] – RSFalcon7 Mar 5 '15 at 14:54
  • Not tried it let me try it now – Gideon Maina Mar 5 '15 at 14:55
  • tee is working fine but it overwrites the previous contents of the log of the previous command trying to solve that now – Gideon Maina Mar 5 '15 at 15:05
  • tee -a option works fine thanks RSFalcon7 awesome. – Gideon Maina Mar 5 '15 at 15:09
4

The error is because you are redirecting all output to $logfile so there is no output for yad to process. The tool you're looking for is tee:

NAME
       tee - read from standard input and write to standard output and files

SYNOPSIS
       tee [OPTION]... [FILE]...

DESCRIPTION
       Copy standard input to each FILE, and also to standard output.

So, you could do:

apt-get update 2>&1 | tee -a ${logfile} |
  yad --width=400 --height=300 \
    --title="Updating debian package list ..." --progress \
    --pulsate --text="Updating debian package list ..." \
    --auto-kill --auto-close \
    --percentage=10 
  • There isn't much on yad in googleland. I found this very helpful two years after it was written. +1 – WinEunuuchs2Unix Apr 1 '17 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.