Show command progress with output of command?

293 views
Skip to first unread message

John Riordan

unread,
Mar 6, 2022, 7:00:33 PM3/6/22
to yad-common
Hi All,

What are the best ways to pipe output of command to YAD progress?  I know you need to lead this output with a # so YAD can capture it. I have tried and tried so many different options but can't seem to get it.  Any suggestions would be so welcomed. 

Thanks in advance,
John

Misko

unread,
Mar 11, 2022, 10:09:28 AM3/11/22
to yad-common
Pipe or Coprocess
#! bash supports only one coprocess

One more thing, yad expects new lines but when using non-interactively,
most standard commands,like grep, buffer the output,
meaning it does not write data immediately to stdout.
It collects large amount of data (depend on OS, in Linux, often 4096 bytes) before writing.
Grep has an option to turn on line buffering:
command | grep --line-buffered | command
With command that does not have option to modify buffer, you can use GNU coreutils stdbuf
tail -f <file> | stdbuf -oL fgrep "string" | sed 's/stuff//g'
With awk you can use fflush() function to unbuffer the output.

Robert Cooper

unread,
Aug 15, 2022, 7:38:58 PM8/15/22
to yad-common
Here is -tails in action   (I am not a programmer but,)  I was able to: STOUT --> File --> Yad Parent using -tails. I did this 5 years ago. I can share my code if others will improve on it.


stdout-tails.png

Robert Cooper

unread,
Aug 15, 2022, 8:06:20 PM8/15/22
to yad-common

John Riordan

unread,
Aug 15, 2022, 11:16:40 PM8/15/22
to yad-c...@googlegroups.com
Thank you! Appreciate it. 

--
You received this message because you are subscribed to a topic in the Google Groups "yad-common" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/yad-common/ivAwSiTxVik/unsubscribe.
To unsubscribe from this group and all its topics, send an email to yad-common+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/yad-common/0534575b-d494-47a8-bc2d-113ff94cd84dn%40googlegroups.com.

Robert Cooper

unread,
Aug 16, 2022, 3:29:11 PM8/16/22
to yad-common
Still looking for code but, here is another video of feedback in action. 

John Riordan

unread,
Aug 16, 2022, 3:39:01 PM8/16/22
to yad-c...@googlegroups.com
Wow thanks so much. I had to do with out the progress I was looking for. However, I would still like to add that piece in the future.  Thanks again!
John

Robert Cooper

unread,
Aug 23, 2022, 7:11:07 PM8/23/22
to yad-common
John, I could not find my original code so I spent a few hours (I'm old and slow and not a programmer) to rework my terminal feedback script. This is only the main code, I will upload the complete code (multiple files and directories) to my github account and post link next post. 

(Starts about 50 seconds)

The below example code opens a yad --text-info window and using -tails command feeds function output, echo, wget -o, etc to the text-info window.  

You will see "yad4" in the below code and its another copy of yad that can be killed with "killall yad4". This way you can have subsets of yads running and close those subsets easily.

_____________________________________Terminal Feedback to yad --text-info window_________________________________

#!/bin/bash
# Script Name: View GTK default icons using yad & bash
# Author: Robert Cooper, Offternet.com
# ver: 1.0
# Date: 2022/08/23
# License: GPL 3
# Research: Yad Gui Group - https://groups.google.com/g/yad-common
# Yad Author is: Victor Ananjevsky

# SPECIAL INSTALL & FUNCTIONALITY Instructions - copy yad to yad2 (or yad4 in below example script)
# For example on Debian.-> sudo cp /usr/local/bin/yad /usr/local/bin/yad2
# yad2 is used to close yad2 windows, etc.

export logFile="/home/yad/launcher/scripts/term-feedback.log"
export logDir="/home/yad/launcher/scripts"
export codeDir="/home/yad/laucher/scripts/source"

rm  $logDir/term-feedback.log
cp $logDir/empty.log $logDir/term-feedback.log

update_vgcode() {
echo "Now updating YADGUI Video Gallery Code" > $logFile
sleep 3
cd /home/yad/launcher/scripts/source/
echo "Directory changed to" >> $logFile
pwd >>  $logFile
echo "Downloading updated config file for YADGUI Video Gallery folder"  >> $logFile
wget -a /home/yad/launcher/scripts/term-feedback.log http://yadgui.com/yad/launcher/scripts/source/import-videos-list.source
echo ""  >> $logFile
echo "" >> $logFile
echo "Closing Connection to YADGUI Server"  >> $logFile
echo "YADGUI Video Gallery Code is Now up to date." >> $logFile
sleep 3
echo "" >> $logFile
echo "Code by Offternet - http://yadgui.com" >> $logFile
echo ""  >> $logFile
echo "ALL DONE !!! Please Click Close Button"  >> $logFile
}
export -f update_vgcode

tail -f $logDir/term-feedback.log | yad4 --text-info --text="Update YADGUI Video Gallery Code" --width=500 --height=500 --on-top --center --button="Update Now":"bash -c update_vgcode" --button="Close:0"  > $logDir/term-feedback.log --tail



Reply all
Reply to author
Forward
0 new messages