[nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Hi There, I'm trying to tail a file in nodejs, the code is this: var fs = require('fs'); var fName = 'file.txt'; fNameStat = fs.statSync(fName); fs.watch(fName, function (evento, arquivo) { fNameStatChanged = fs.statSync(arquivo); console.log('file changed from ' + fNameStat.size + ' to ' +

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
Hello! Perhaps, you are trying to create a Buffer of negative length? Also, I believe, that you do not need to pass encoding argument to the Buffer's constructor if you're creating just a fixed-size buffer. On Mon, Dec 9, 2013 at 1:58 PM, Felipe Silveira cont...@felipems.com.br wrote: Hi

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Thank bro to help, I change to this code and get the same error: var fs = require('fs'); var fName = 'text.txt'; fNameStat = fs.statSync(fName); fs.watch(fName, function (evento, arquivo) { fNameStatChanged = fs.statSync(arquivo); console.log('file changed from ' + fNameStat.size + ' to ' +

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
What does it log to console? What node.js version are you using? On Mon, Dec 9, 2013 at 2:17 PM, Felipe Silveira cont...@felipems.com.br wrote: Thank bro to help, I change to this code and get the same error: var fs = require('fs'); var fName = 'text.txt'; fNameStat = fs.statSync(fName);

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Console fs.js:267 binding.read(fd, buffer, offset, length, position, wrapper); ^ Error: Offset is out of bounds at Object.read (fs.js:267:11) at Object.oncomplete (/var/www/leitor/teste.js:16:15) Node Version v0.6.17 *Att,* *Felipe Silveira Mendes*Site

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
You're logging much more data than this, are you sure it prints out only the error? And also you forgot to include version number of node.js that you're using. On Mon, Dec 9, 2013 at 2:23 PM, Felipe Silveira cont...@felipems.com.br wrote: Console fs.js:267 binding.read(fd, buffer, offset,

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Yes yes, i'm loggin just what I got on the console...the node version is v0.6.17 *Att,* *Felipe Silveira Mendes*Site http://felipems.com.br - Twitterhttps://twitter.com/felipesmendes- Blog http://felipems.com.br/blog *Web Developer* *(31) 8370-9090 (Claro)* *(31) 9433-9310 (Tim)*

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
Hm... this version is really really old, may I ask you to try upgrading to at least v0.6.21 ? (Would be much better to give a try to latest 0.10, or 0.8). On Mon, Dec 9, 2013 at 2:29 PM, Felipe Silveira cont...@felipems.com.br wrote: Yes yes, i'm loggin just what I got on the console...the node

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Ok, How can I upgrade my node? I'm using ubuntu 10.10 and can I do it with apt-get or aptitude? What comands I need to do? *Att,* *Felipe Silveira Mendes*Site http://felipems.com.br - Twitterhttps://twitter.com/felipesmendes- Blog http://felipems.com.br/blog *Web Developer* *(31) 8370-9090

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
Depends on what ppa are you using. I'd recommend trying: https://launchpad.net/~chris-lea/+archive/node.js/ On Mon, Dec 9, 2013 at 2:37 PM, Felipe Silveira cont...@felipems.com.br wrote: Ok, How can I upgrade my node? I'm using ubuntu 10.10 and can I do it with apt-get or aptitude? What

Re: [nodejs] Tail file with node.

2013-12-09 Thread Brian Di Palma
It's very easy to compile it yourself. On Mon, Dec 9, 2013 at 10:37 AM, Felipe Silveira cont...@felipems.com.br wrote: Ok, How can I upgrade my node? I'm using ubuntu 10.10 and can I do it with apt-get or aptitude? What comands I need to do? Att, Felipe Silveira Mendes Site - Twitter -

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
I updated my node js to version *v0.10.22* and installed nodejs-dbg for debug and getting the same error: fs.js:457 binding.read(fd, buffer, offset, length, position, wrapper); ^ Error: Offset is out of bounds at Object.fs.read (fs.js:457:11) at /var/www/read/test.js:16:15

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
So, don't tell me it isn't printing anything else :) You have a lot of console.log()s there. Can you paste them here? On Mon, Dec 9, 2013 at 6:46 PM, Felipe Silveira cont...@felipems.com.br wrote: I updated my node js to version v0.10.22 and installed nodejs-dbg for debug and getting the same

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Ooh Sorry yeah I forgot, here is: file changed from 101644 to 101650 file changed from 101644 to 101650 file changed from 101644 to 101650 6 Buffer 8c e0 0f 09 ac ad 11 0 Buffer 12 *Att,* *Felipe Silveira Mendes*Site http://felipems.com.br - Twitterhttps://twitter.com/felipesmendes- Blog

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
Ok, so you create 0 length buffer here, and doing 0-size read :) That's totally not supported. On Mon, Dec 9, 2013 at 6:57 PM, Felipe Silveira cont...@felipems.com.br wrote: Ooh Sorry yeah I forgot, here is: file changed from 101644 to 101650 file changed from 101644 to 101650 file changed

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Sorry, I didn't understand, what I need to do on the code? *Att,* *Felipe Silveira Mendes*Site http://felipems.com.br - Twitterhttps://twitter.com/felipesmendes- Blog http://felipems.com.br/blog *Web Developer* *(31) 8370-9090 (Claro)* *(31) 9433-9310 (Tim)* *cont...@felipems.com.br

Re: [nodejs] Tail file with node.

2013-12-09 Thread Fedor Indutny
You should not read if len === 0. On Mon, Dec 9, 2013 at 7:02 PM, Felipe Silveira cont...@felipems.com.br wrote: Sorry, I didn't understand, what I need to do on the code? Att, Felipe Silveira Mendes Site - Twitter - Blog Web Developer (31) 8370-9090 (Claro) (31) 9433-9310 (Tim)

Re: [nodejs] Tail file with node.

2013-12-09 Thread Felipe Silveira
Like This? var fs = require('fs'); var fName = 'test.txt; fNameStat = fs.statSync(fName); fs.watch(fName, function (evento, arquivo) { fNameStatChanged = fs.statSync(arquivo); console.log('file changed from ' + fNameStat.size + ' to ' + fNameStatChanged.size); fs.open(fName, 'r', function(err,