Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Okay, bear with me on this. I'm using a program called BFGminer, which hopefully you know is a bitcoin mining program. Anyway. It updates every second a few lines that look like this:

DEVICE 0: xxxx
DEVICE 1: xxxx

This is just the basics of what I am concerned about. I need a way to view these few lines from a terminal window if possible. The only issue that I have is that I can not seem to get grep to update the pipe I have coming into it.

I have the command running on another machine, and that machine also has a screen with BFGminer running.

So to access BFGminer's window, I am running a script to

ssh user@192.1681.1.11 screen -R

This gets me to the screen, but I have to press ctrl+A, then D to detach it so it will continue to run.

If I run

ssh user@192.1681.1.11 screen -R | grep "^ DEV"

I can view all devices connected. Good so far. However, it does not update every few seconds like I need it to...

EDITED: figured out what to do. See answer.

share|improve this question
    
don't know if you can find help here. but if you cannot, mayby you could try here to: bitcoin.stackexchange.com –  Rat2000 Aug 8 '13 at 7:58
    
This is more about getting grep to update at a certain rate. As far as I know, grep only runs the command once. It doesn't update its output if the program that has its output | to grep updates the same line with the current information. If there is a command that showed you the temperature of parts in your computer, and updated the same line instead of making a new one, and you wanted to grab just part of its output, it would be the same thing as I am trying to do here. –  Flasimbufasa Aug 8 '13 at 13:50
    
I have no answer for this, but I guess the problem here is less not grep. Since you are piping the output to the less program every 2 seconds, you are not in fact updating its content. Check this answer on Unix & Linux - Is there a way to dynamically refresh the less command?. –  Dan Aug 8 '13 at 14:06

2 Answers 2

up vote 0 down vote accepted
ssh user@192.1681.1.11 ./RPC.sh

RPC.sh contains:

cd /opt/bfgminer/
while : ; do clear && ./bfgminer-rpc && sleep 5; done;

Looks like: http://pastebin.com/wrTb18TL

Does a good enough job. It just doesn't have all the info I need. I'll make a new question later for trying to analyze the data if I can't figure it out.

Thanks everyone for the ideas :)

EXPLANATION: turns out bfgminer has a RPC (Remote procedure call) feature. All you need to do is add a flag when you start bfgminer. "--enable-api"

I haven't figured out how to tidy up the output yet using grep. But at least this will update properly with some of the needed information.

share|improve this answer

Use tail, it will follow a file as it grows. You can pipe tail into grep: tail changing-log-file | grep whatever-you-need. You can have BFGminer produce a logfile you can tail with the -L parameter apparently, use -L /path/to/file. Then on your local system you can do something like:

ssh server.com tail -f /path/to/file | grep DEVwhatever

just Ctrl+C this process when you want to stop following the log.

Happy mining!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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