This one is for coders:
function genoil_statics ()
{
#### Arrange the output for Genoil statics
if [[ "$ETHMINER_or_GENOIL_or_CLAYMORE" == "GENOIL" ]]; then
# Check if Genoil is running. Note that I have to search the full path as there is a few miners with the same exec's name
ps aux | grep -v grep | grep miner | grep -q "$KEY_GENOIL"
if [[ $? -eq 0 ]]; then
GENOIL_IS_RUNNING="YES"
TIMEOUT_FOR_TIMEOUT_IN_SECONDS=20 # The timeout for the command timeout to wait
GENOIL_NUMBER_OF_HASHRATES_TO_SHOW=3 # Default 3, and I want to keep this value independent for each miner
echo
echo "It seems that GENOIL is running!!"
# Extract the output from screen
echo "Running timeout+script+screen for $TIMEOUT_FOR_TIMEOUT_IN_SECONDS seconds"
timeout $TIMEOUT_FOR_TIMEOUT_IN_SECONDS script -q ~/kk003_telegram_data/files/output_miner_from_screen --command "screen -dr miner"
sleep 2
# screen -d miner # does not seem to need to be Detached
# I don't see any valuable information than the total hashrate (I'll show a few at last)
# Surprise!!!, sed 's/ /\n/g' no convierte espacios en saltos de linea, pero la misma linea en la consola si lo hace!!!
TOTAL_HASHRATE=$(cat ~/kk003_telegram_data/files/output_miner_from_screen | grep "Mining on PoWhash" | cut -d":" -f4 | cut -d" " -f2 | sed 's/ /\n/g' | tail -$GENOIL_NUMBER_OF_HASHRATES_TO_SHOW
# Mount the little thing Genoil gives us
#
echo "Latest total hashrates : " > ~/kk003_telegram_data/files/miner_statics.txt
echo $TOTAL_HASHRATE >> ~/kk003_telegram_data/files/miner_statics.txt
echo "Latest total hashrates : " > ~/kk003_telegram_data/files/miner_statics_log_file.txt
echo $TOTAL_HASHRATE >> ~/kk003_telegram_data/files/miner_statics_log_file.txt
# Insert the Title for Genoil mining information
sed -i "1s/^/** Genoil mining Information **\n/" ~/kk003_telegram_data/files/miner_statics.txt
sed -i "1s/^/\n/" ~/kk003_telegram_data/files/miner_statics.txt
sed -i "1s/^/** Genoil mining Information **\n/" ~/kk003_telegram_data/files/miner_statics_log_file.txt
sed -i "1s/^/\n/" ~/kk003_telegram_data/files/miner_statics_log_file.txt
else
echo "Genoil does not seem to be running!!. Skiping this bit."
GENOIL_IS_RUNNING="NO"
fi
fi
}
I found out a way to capture the output from screen in real time. See the lines:
# Extract the output from screen
echo "Running timeout+script+screen for $TIMEOUT_FOR_TIMEOUT_IN_SECONDS seconds"
timeout $TIMEOUT_FOR_TIMEOUT_IN_SECONDS script -q ~/kk003_telegram_data/files/output_miner_from_screen --command "screen -dr miner"
sleep 2
# screen -d miner # does not seem to need to be Detached
This run screen for 20 seconds (timeout command) and saves output to file ~/kk003_telegram_data/files/output_miner_from_screen (script command). -dr forces to attach miner (so if user have screen open in a terminal will close it and the script will do its job). After 20 seconds miner is detached without need to send CTRL+d.
This works better if ran from a non interactive terminal, ejem: from nvoc system

.
This means it is possible to capture the output of any miner even if all of it shows only on terminal (no log file, web server, argument -L on screen, etc).
I hope it will be useful for you too.
PD: if you use "tail -f file" to watch the output in real time don't trust what you see. The real output is in the file (do a cat file or whatever). Keep in main, if you log the output of your script probably you'll get those 20 seconds from screen in the log file too.