`tail -f app.log | grep error`
there is a .pipe() hidden here. Oh wait, here it is:
var spawn = require('child_process').spawn,
tail = spawn('tail', ['-f','app.log']),
grep = spawn('grep', ['error']);
tail.stdout.pipe(grep.stdin)
grep.stdout.pipe(whateverStream)
of course its all untested, but just to give a hint
Am Dienstag, 10. Juni 2014 11:48:44 UTC+2 schrieb Alexey Petrushin:
>
> Hi, I'd like to provide administrative app with a page when you can see
> live logs. To do so I need to execute `tail -f app.log | grep error` and
> get the output chunk by chunk (streaming) as it get added to log file. But
> the problem is:
>
> 1. child_process.exec doesn't have streaming, it return only when the
> child process is terminated
> 2. child_process.spawn does have streaming, but it can execute only
> commands, it can't execute complex expressions like `tail -f app.log | grep
> error`
>
> Is there an easy way to solve it?
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/e3e9efdb-ad65-409e-b119-1693522e8535%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.