Re: [FUG-BR] OT - Monitorar alterações de arquivo
você pode usar o aide ele gerar um baco de dados das pastas que vc que e depois vc pode fazer teste para ver se algo foi alterado e ele te da um relatorio de q ofi alterado da data hora eu use muito em linux no free nao testei mas deve funcionanr sem problemas - Original Message - From: "irado furioso com tudo" <[EMAIL PROTECTED]> To: Sent: Monday, June 12, 2006 9:23 AM Subject: Re: [FUG-BR] OT - Monitorar alterações de arquivo Em Sat, 10 Jun 2006 00:48:18 + "NgD Vulto" <[EMAIL PROTECTED]> escreveu: > Você pode tentar fazer um script que receba o tamanho do arquivo de > tempo em tempo (isso não come tanto processamento, é quase nada, se > você usar as ferramentas como o sleep por exemplo) me metendo no assunto (sem ser chamado), eu preferiria usar o MD5 pra conferir arquivos. --- --- saudações, irado furioso com tudo Linux User 179402/FreeBSD BSD50853 mulheres são como piscinas: custam caro demais para o tempo que permanecemos dentro delas. - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.3/361 - Release Date: 11/6/2006 - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd
Re: [FUG-BR] OT - Monitorar alterações de arquivo
Em Sat, 10 Jun 2006 00:48:18 + "NgD Vulto" <[EMAIL PROTECTED]> escreveu: > Você pode tentar fazer um script que receba o tamanho do arquivo de > tempo em tempo (isso não come tanto processamento, é quase nada, se > você usar as ferramentas como o sleep por exemplo) me metendo no assunto (sem ser chamado), eu preferiria usar o MD5 pra conferir arquivos. --- --- saudações, irado furioso com tudo Linux User 179402/FreeBSD BSD50853 mulheres são como piscinas: custam caro demais para o tempo que permanecemos dentro delas. - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd
Re: [FUG-BR] OT - Monitorar alterações de arquivo
Pedro Henrique Morsch Mazzoni wrote: > Olá pessoal, > > Estou procurando um modo de rodar um script sempre que um arquivo > determinado seja alterado. > Preciso de algo que não ocupe CPU ( loops :) ). Também não pode ser o FAM. > Alguma dica? man kqueue(2) and googleit Abraços > > Grato, > Pedro MAzzoni > - > Histórico: http://www.fug.com.br/historico/html/freebsd/ > Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd -- Marcus Alves Grando marcus(at)corp.grupos.com.br | Grupos Internet S/A mnag(at)FreeBSD.org | FreeBSD.org - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd
Re: [FUG-BR] OT - Monitorar alterações de arquivo
2006/6/10, Eduardo Alvarenga <[EMAIL PROTECTED]>: > Certo dia, recebi um arquivo na lista freebsd-hackers, que funcionou> muito bem; testei algumas vezes, funcionou OK, e tenho ele guardado na> manga para caso alguem dia utilize; bem, chegou o dia: > compile usando: gcc -o fwatch fwatch.c>> fwatch.c> > /*> * Copyright (c) 2003-2004 Daichi GOTO < [EMAIL PROTECTED]>> * All rights reserved.Não tem manual?Grande abraço,--Eduardo Alvarenga-Histórico: http://www.fug.com.br/historico/html/freebsd/Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsdAnalisando o código, percebe-se que você precisa digitar fwatch e o arquivo que você quer monitorar. Isso se você tiver compilado com esse nome ;) por falar nisso você conseguiu ao menos compilar?se não, é provável que você não tenha algumas das bibliotecas usadas no include.Ats,Hugo Pessoa/NgD. -- [Freebsd User Group]Fug-Br/BsD-Ce/Fug-Ce/Freebsd-Questions proud active member.There will be a day machines will reign, and only the ones able to understand them will survive. - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd
Re: [FUG-BR] OT - Monitorar alterações de arquivo
> Certo dia, recebi um arquivo na lista freebsd-hackers, que funcionou > muito bem; testei algumas vezes, funcionou OK, e tenho ele guardado na > manga para caso alguem dia utilize; bem, chegou o dia: > compile usando: gcc -o fwatch fwatch.c > > fwatch.c > > /* > * Copyright (c) 2003-2004 Daichi GOTO <[EMAIL PROTECTED]> > * All rights reserved. Não tem manual? Grande abraço, -- Eduardo Alvarenga - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd
Re: [FUG-BR] OT - Monitorar alterações de arquivo
Certo dia, recebi um arquivo na lista freebsd-hackers, que funcionou muito bem; testei algumas vezes, funcionou OK, e tenho ele guardado na manga para caso alguem dia utilize; bem, chegou o dia: compile usando: gcc -o fwatch fwatch.c fwatch.c /* * Copyright (c) 2003-2004 Daichi GOTO <[EMAIL PROTECTED]> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #define kevent_add(kq, ev) kevent((kq), (ev), 1, NULL, 0, NULL) #define kevent_poll(kq, ev) kevent((kq), NULL, 0, (ev), 1, NULL) static void usage(void); static void addwatchfile(int, int); static void watchfile(int); int main(int argc, char *argv[]) { int kq; int filedesc; int count; if (2 > argc) { usage(); exit(EX_USAGE); } kq = kqueue(); for (count = 1; count < argc; count++) { filedesc = open(argv[count], O_RDONLY); if (-1 == filedesc) { fprintf(stderr, "error: cannot open file: %d\n", errno); exit(EX_NOINPUT); } addwatchfile(kq, filedesc); } watchfile(kq); exit(EX_OK); } static void usage(void) { fprintf(stderr, "usage: fwatch files...\n"); } static void addwatchfile(int kq, int filedesc) { struct kevent event; EV_SET(&event, filedesc, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME, 0, 0); kevent_add(kq, &event); } static void watchfile(int kq) { struct kevent event; kevent_poll(kq, &event); } On 6/9/06, Pedro Henrique Morsch Mazzoni <[EMAIL PROTECTED]> wrote: > Olá pessoal, > > Estou procurando um modo de rodar um script sempre que um arquivo > determinado seja alterado. > Preciso de algo que não ocupe CPU ( loops :) ). Também não pode ser o FAM. > Alguma dica? > > Grato, > Pedro MAzzoni > - > Histórico: http://www.fug.com.br/historico/html/freebsd/ > Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd > - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd
Re: [FUG-BR] OT - Monitorar alterações de arquivo
2006/6/10, Pedro Henrique Morsch Mazzoni <[EMAIL PROTECTED]>: Olá pessoal,Estou procurando um modo de rodar um script sempre que um arquivodeterminado seja alterado.Preciso de algo que não ocupe CPU ( loops :) ). Também não pode ser o FAM.Alguma dica?Grato, Pedro MAzzoni-Histórico: http://www.fug.com.br/historico/html/freebsd/Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsdUm arquivo é alterado quando muda de tamanho, seja para mais ou para menos, as chances de um arquivo ser alterado e manter o exato mesmo tamanho em KB é a mesma de um trovão acertar o mesmo lugar duas vezes, apesar de não ser totalmente impossível é muito improvável. Você pode tentar fazer um script que receba o tamanho do arquivo de tempo em tempo (isso não come tanto processamento, é quase nada, se você usar as ferramentas como o sleep por exemplo) e se o valor for diferente do valor antigo, executar o que você quer, então ele deve guardar o valor novo do tamanho do arquivo, e verificar de tempo em tempo...e...se for diferente do valor guardado fazer o mesmo processo, como programador posso te dizer que é possível fazer isso usando C, entretanto não terei tempo para escrever isso agora, recomendo que absorva minha ideia e transforme em algo de útil no meio de suas habilidades. Como dica deixo aqui que fazendo du -k arquivo retornará o tamanho dele e você poderá arrumar um jeito de filtrar e passar esse valor para seu script/programa com segundas intenções.Qualquer dúvida relacionada ao que eu falei me mantenha informado, desde que não me coloque pra codar, é claro hehe :) Ats,Hugo Pessoa/NgD.-- [Freebsd User Group]Fug-Br/BsD-Ce proud active member.There will be a day machines will reign, and only the ones able to understand them will survive. - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd
[FUG-BR] OT - Monitorar alterações de arquivo
Olá pessoal, Estou procurando um modo de rodar um script sempre que um arquivo determinado seja alterado. Preciso de algo que não ocupe CPU ( loops :) ). Também não pode ser o FAM. Alguma dica? Grato, Pedro MAzzoni - Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd