Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
On Fri, Jan 12, 2001 at 12:45:29PM -0500, Erdmut Pfeifer wrote: [-->8-- a very nice'n'quick script ---] Perfect! Thanks to all who replied, all your suggestions were helpful. I'll probably use Erdmut's script as it's so "nice, short and clean" and because I just love Perl. :) -- Maciej Kalisiak [EMAIL PROTECTED] www.dgp.toronto.edu/~mac
Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
On Thu, Jan 11, 2001 at 07:58:00PM -0500, D-Man wrote: > On Thu, Jan 11, 2001 at 07:35:06PM -0500, Chris Gray wrote: > | > D-Man writes: > | > | d> | How is mutt (or any other MUA) meant to do it then? > | d> | > | > | d> By checking the file itself for new messages, rather than > | d> relying on the timestamp. Some MUA's handle new messages in > | d> folders better. (ie, you can open up the mailbox, not read > | d> anything, and it still says new -- mutt doesn't) > | > | Only now, when the user has 1e6 messages in his inbox because he > | never deletes any, he opens mutt and then goes on his coffee break and > | gets back before mutt is done scanning the messages. Also, where is > > Yeah, it's not perfect. As I said in my quoted paragraph below the > current system probably solves a lot of developer headaches with such > situations. Who's going to save 1e6 messages anyways? Even if you > do, are you even going to remember any but the last dozen or so? (but > I'm not going to argue the point so don't bother answering the q's :-)) > > | mutt supposed to keep the information about which messages were > | previously in the folder? > | > > In the folder itself. There is a header that has this info, just > open it in vim or something. I did some checking just now and > couldn't find it in my mutt mbox. I have seen it before. I think > Netscape messenger sets such a header. Something like X-Status. The > flags for the header that I am aware of are "R" "O" and "N". Have you > ever noticed how even if mutt doesn't list the folder as new in the > folder view it still reports the messages properly once the folder is > opened? > > | d> All-in-all though it's not such a bad system (for mutt). It > | d> probably solves a lot of headaches with locks and other > | d> processes trying to write to the mbox as mutt reads to > | d> determine if something is new or not. > | > | What is "it" here? Futzing around scanning the mailbox or doing a > | stat()? I hope you mean the latter. > | > > Checking the timestamp. (I guess that's what stat() does, I haven't > had a need to use stat() in any progs yet) > > | Incidentally, it appears from the stat(2) man page that a solution > | to this problem might be unmounting, mounting with the option > | "noatime", and then remounting without that option. It also appears > | that 'touch' can change the access time of the file with the -a flag. > | But I think I'm coming in on the end of this thread and that might > > I just joined the thread when the subject changed. I did know that > touch will set the last (modfied/accessed) time to now, and if the > file DNE it will create it. > > | have already been suggested. Also, if you know that your mailbox has > | new mail, you can > > If I know it has new mail, then I already know. The goal is to > have the MUA tell me instead. ;-) > > -D You have the source code. Fix this non-problem yourself ... since what you want to do causes it :) Cliff > > > -- > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] >
Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
On Fri, Jan 12, 2001 at 02:11:58PM +, David Wright wrote: > > (...) > > The idea that mutt should have to scan all my inboxes to determine > whether I have new mail is bad enough; the idea that the inboxes > should be rewritten (not even just appended to) would be crazy. right, I'd definitely agree! > The status quo is automatic (that's how timestamps work), lightweight > and works. If you must grep your active inboxes, it seems a small price > to pay to have to reapply the access timestamps. a small wrapper script (in Perl -- I know one could do that in at least 25 other languages as well ;-) to restore timestamps after running some program over a set of files might look something like: #!/usr/bin/perl while ($ARGV[$c] =~ /^-/) {$c++}; # find first 'non-option' @files = @ARGV[++$c..$#ARGV]; # filelist begins after search-regex # (extraction of filelist from commandline might need to be improved...) # get atime/mtime for all files foreach $f (@files) { push @times, [(stat $f)[8,9], $f]; # 8: atime, 9: mtime } # run your favourite grep or whatever here: system "grep @ARGV"; # restore atime/mtime for all files foreach $f (@times) { utime @$f; } You would call it more or less like grep. Assuming you name it mygrep: mygrep [options] search-regex files... Cheers, Erdmut -- Erdmut Pfeifer science+computing gmbh -- Bugs come in through open windows. Keep Windows shut! --
Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
Quoting D-Man ([EMAIL PROTECTED]): > | Also, where is > | mutt supposed to keep the information about which messages were > | previously in the folder? > | > > In the folder itself. There is a header that has this info, just > open it in vim or something. I did some checking just now and > couldn't find it in my mutt mbox. I have seen it before. I think > Netscape messenger sets such a header. Something like X-Status. Status. Just press (H)eaders to see all the headers. If you still can't see the status, then you're probably looking at an email that was New when you entered the mailbox. Just ($)ync the mailbox (or (C)hange to the same mailbox) and the three extra headers will appear. You wrote "There is a header". But these flags are for *each message*. There is no global header that remembers whether you entered the mailbox itself. You would have to scan all the emails to see if there were any without a Status header to decide if there were any new emails in that folder. > | d> All-in-all though it's not such a bad system (for mutt). It > | d> probably solves a lot of headaches with locks and other > | d> processes trying to write to the mbox as mutt reads to > | d> determine if something is new or not. > I just joined the thread when the subject changed. I changed the subject. I wanted to know why R. Ransbottom ([EMAIL PROTECTED]) felt that a bug report should be filed against mutt, and what the bug was. There has been no response yet. The idea that mutt should have to scan all my inboxes to determine whether I have new mail is bad enough; the idea that the inboxes should be rewritten (not even just appended to) would be crazy. The status quo is automatic (that's how timestamps work), lightweight and works. If you must grep your active inboxes, it seems a small price to pay to have to reapply the access timestamps. Cheers, -- Email: [EMAIL PROTECTED] Tel: +44 1908 653 739 Fax: +44 1908 655 151 Snail: David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA Disclaimer: These addresses are only for reaching me, and do not signify official stationery. Views expressed here are either my own or plagiarised.
Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
> D-Man writes: d> | "noatime", and then remounting without that option. It also appears d> | that 'touch' can change the access time of the file with the -a flag. d> | But I think I'm coming in on the end of this thread and that might d> I just joined the thread when the subject changed. I did know that d> touch will set the last (modfied/accessed) time to now, and if the d> file DNE it will create it. You can also use touch to set the timestamp to a different time. d> | have already been suggested. Also, if you know that your mailbox has d> | new mail, you can d> If I know it has new mail, then I already know. The goal is to d> have the MUA tell me instead. ;-) I think you missed the point of the script I attached. It allows you to do just that. Chris -- Got jag? http://www.tribsoft.com
Re: how to grep without changing timestamps?
>On Sun, Dec 31, 2000 at 02:04:57PM -0500, Maciej Kalisiak wrote: > Hello all, > > Is it possible to grep a ton of files without modifying their > >date/timestamps? Currently if I use grep, it changes the access time of all > >files touched, which causes mutt to lose track of the folders which have > >new mail (I guess it looks at the timestamp last modified and last accessed > >to figure this out). Occasionally I do want to include the mail folders in > >my greps, so bypassing the "mail" directory is not a solution. It is possible to disable access timestamp. You have to remount the partition using "noatime" option. "find" will work app. 25% faster (tar 19%, cvs 8.6%). Regards Mikhail
Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
On Thu, Jan 11, 2001 at 07:35:06PM -0500, Chris Gray wrote: | > D-Man writes: | | d> | How is mutt (or any other MUA) meant to do it then? | d> | | | d> By checking the file itself for new messages, rather than | d> relying on the timestamp. Some MUA's handle new messages in | d> folders better. (ie, you can open up the mailbox, not read | d> anything, and it still says new -- mutt doesn't) | | Only now, when the user has 1e6 messages in his inbox because he | never deletes any, he opens mutt and then goes on his coffee break and | gets back before mutt is done scanning the messages. Also, where is Yeah, it's not perfect. As I said in my quoted paragraph below the current system probably solves a lot of developer headaches with such situations. Who's going to save 1e6 messages anyways? Even if you do, are you even going to remember any but the last dozen or so? (but I'm not going to argue the point so don't bother answering the q's :-)) | mutt supposed to keep the information about which messages were | previously in the folder? | In the folder itself. There is a header that has this info, just open it in vim or something. I did some checking just now and couldn't find it in my mutt mbox. I have seen it before. I think Netscape messenger sets such a header. Something like X-Status. The flags for the header that I am aware of are "R" "O" and "N". Have you ever noticed how even if mutt doesn't list the folder as new in the folder view it still reports the messages properly once the folder is opened? | d> All-in-all though it's not such a bad system (for mutt). It | d> probably solves a lot of headaches with locks and other | d> processes trying to write to the mbox as mutt reads to | d> determine if something is new or not. | | What is "it" here? Futzing around scanning the mailbox or doing a | stat()? I hope you mean the latter. | Checking the timestamp. (I guess that's what stat() does, I haven't had a need to use stat() in any progs yet) | Incidentally, it appears from the stat(2) man page that a solution | to this problem might be unmounting, mounting with the option | "noatime", and then remounting without that option. It also appears | that 'touch' can change the access time of the file with the -a flag. | But I think I'm coming in on the end of this thread and that might I just joined the thread when the subject changed. I did know that touch will set the last (modfied/accessed) time to now, and if the file DNE it will create it. | have already been suggested. Also, if you know that your mailbox has | new mail, you can If I know it has new mail, then I already know. The goal is to have the MUA tell me instead. ;-) -D
Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
> D-Man writes: d> | How is mutt (or any other MUA) meant to do it then? d> | d> By checking the file itself for new messages, rather than d> relying on the timestamp. Some MUA's handle new messages in d> folders better. (ie, you can open up the mailbox, not read d> anything, and it still says new -- mutt doesn't) Only now, when the user has 1e6 messages in his inbox because he never deletes any, he opens mutt and then goes on his coffee break and gets back before mutt is done scanning the messages. Also, where is mutt supposed to keep the information about which messages were previously in the folder? d> All-in-all though it's not such a bad system (for mutt). It d> probably solves a lot of headaches with locks and other d> processes trying to write to the mbox as mutt reads to d> determine if something is new or not. What is "it" here? Futzing around scanning the mailbox or doing a stat()? I hope you mean the latter. Incidentally, it appears from the stat(2) man page that a solution to this problem might be unmounting, mounting with the option "noatime", and then remounting without that option. It also appears that 'touch' can change the access time of the file with the -a flag. But I think I'm coming in on the end of this thread and that might have already been suggested. Also, if you know that your mailbox has new mail, you can echo "" >> $mailbox which has the effect of making the modification time greater than the access time, which will make mutt put an N next to the mailbox. This suggests a script, which isn't perfect but works: #!/bin/bash if [ $# -ne "2" ]; then echo "usage: $0 pattern file" exit 1 fi atime=`stat -t $2 | cut -f 12 -d " "` mtime=`stat -t $2 | cut -f 13 -d " "` makenew=false if [ $atime -lt $mtime ]; then makenew=true fi grep $1 $2 if $makenew; then sleep 2 # make sure that the atime and mtime are on different # seconds echo "" >> $2 fi Cheers, Chris -- Got jag? http://www.tribsoft.com
Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
On Thu, Jan 11, 2001 at 06:04:42PM +, David Wright wrote: | Quoting R. Ransbottom ([EMAIL PROTECTED]): | | > > on Sun, Dec 31, 2000 at 02:04:57PM -0500, Maciej Kalisiak ([EMAIL PROTECTED]) wrote: | > > > Is it possible to grep a ton of files without modifying their | > > > date/timestamps? Currently if I use grep, it changes the access time | > > > of all files touched, which causes mutt to lose track of the folders | > > > which have new mail (I guess it looks at the timestamp last modified | > > > and last accessed to figure this out). Occasionally I do want to | | > - File a bug report on mutt. This is a matter of mutt not playing | > well with others. | | How is mutt (or any other MUA) meant to do it then? | By checking the file itself for new messages, rather than relying on the timestamp. Some MUA's handle new messages in folders better. (ie, you can open up the mailbox, not read anything, and it still says new -- mutt doesn't) All-in-all though it's not such a bad system (for mutt). It probably solves a lot of headaches with locks and other processes trying to write to the mbox as mutt reads to determine if something is new or not. -D
MUAs and timestamps, was Re: how to grep without changing timestamps?
Quoting R. Ransbottom ([EMAIL PROTECTED]): > > on Sun, Dec 31, 2000 at 02:04:57PM -0500, Maciej Kalisiak ([EMAIL > > PROTECTED]) wrote: > > > Is it possible to grep a ton of files without modifying their > > > date/timestamps? Currently if I use grep, it changes the access time > > > of all files touched, which causes mutt to lose track of the folders > > > which have new mail (I guess it looks at the timestamp last modified > > > and last accessed to figure this out). Occasionally I do want to > - File a bug report on mutt. This is a matter of mutt not playing > well with others. How is mutt (or any other MUA) meant to do it then? Cheers, -- Email: [EMAIL PROTECTED] Tel: +44 1908 653 739 Fax: +44 1908 655 151 Snail: David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA Disclaimer: These addresses are only for reaching me, and do not signify official stationery. Views expressed here are either my own or plagiarised.
Re: how to grep without changing timestamps?
On Sun, 31 Dec 2000 kmself@ix.netcom.com wrote: > on Sun, Dec 31, 2000 at 02:04:57PM -0500, Maciej Kalisiak ([EMAIL PROTECTED]) > wrote: > > Is it possible to grep a ton of files without modifying their > > date/timestamps? Currently if I use grep, it changes the access time > > of all files touched, which causes mutt to lose track of the folders > > which have new mail (I guess it looks at the timestamp last modified > > and last accessed to figure this out). Occasionally I do want to > Several hacks come to mind: > > - Copy the files and grep the copies (does this change the > timestamps?) > > - Remount the partition read-only. > > - Build a tool to check timestamps, save them, grep the files, then > reapply the timestamps with 'touch'. - File a bug report on mutt. This is a matter of mutt not playing well with others.
Re: how to grep without changing timestamps?
On Tue, Jan 02, 2001 at 03:14:34AM -0500, will trillich wrote: > > Is it possible to grep a ton of files without modifying their > > date/timestamps? > > Currently if I use grep, it changes the access time of all files touched, > > which causes mutt to lose track of the folders which have new mail (I guess > > it > > looks at the timestamp last modified and last accessed to figure this out). > > Occasionally I do want to include the mail folders in my greps, so bypassing > > the "mail" directory is not a solution. > > whoa. isn't there a difference between MODIFIED and ACCESSED? > doing "pager < file" should modify the ACCESSED timestamp, > but not the MODIFIED timestamp, right? or am i in the wrong > universe? They are different. The way the quick mailcheck works I believe is that, among other things, you check whether modify time > access time. This is because when mail is appended to your spool file, the modify time stamp is updated, but not the access one. The access time stamp is then modified when you actually look at the spool file (with some sort of disk/file "read" operation). -- Maciej Kalisiak [EMAIL PROTECTED] www.dgp.toronto.edu/~mac
Re: how to grep without changing timestamps?
You need to make sure that something calls utime() to reset the filestamps. You can't reset the ctime (inode change time), but the atime (inode access time) and the mtime (inode timestamp) are changable. Here is a simple example Perl script that works a little like grep: -- #!/usr/bin/perl use strict; my ($regexp); $regexp = shift @ARGV; for my $filename (@ARGV) { my @stat = stat $filename or do { print STDERR "stat of $filename failed; $!\n"; next; }; open FILE, "<$filename" or do { print STDERR ("open of $filename for reading failed; " ."$!\n"); next; }; while () { m/$regexp/ && print "$filename: $_"; } close FILE; utime @stat[8,9], $filename or print STDERR "utime call of $filename failed; $!\n"; } -- Cheers, Sam. On Sun, 31 Dec 2000 14:04:57 -0500 Maciej Kalisiak <[EMAIL PROTECTED]> wrote: > Hello all, > > Is it possible to grep a ton of files without modifying their date/timestamps? > Currently if I use grep, it changes the access time of all files touched, > which causes mutt to lose track of the folders which have new mail (I guess it > looks at the timestamp last modified and last accessed to figure this out). > Occasionally I do want to include the mail folders in my greps, so bypassing > the "mail" directory is not a solution. > > -- > Maciej Kalisiak [EMAIL PROTECTED] www.dgp.toronto.edu/~mac > > > -- > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] > > > -- Sam Vilain, [EMAIL PROTECTED]WWW: http://sam.vilain.net/ GPG public key: http://sam.vilain.net/sam.asc
Re: how to grep without changing timestamps?
On Sun, Dec 31, 2000 at 02:04:57PM -0500, Maciej Kalisiak wrote: > Hello all, > > Is it possible to grep a ton of files without modifying their date/timestamps? > Currently if I use grep, it changes the access time of all files touched, > which causes mutt to lose track of the folders which have new mail (I guess it > looks at the timestamp last modified and last accessed to figure this out). > Occasionally I do want to include the mail folders in my greps, so bypassing > the "mail" directory is not a solution. whoa. isn't there a difference between MODIFIED and ACCESSED? doing "pager < file" should modify the ACCESSED timestamp, but not the MODIFIED timestamp, right? or am i in the wrong universe? % ls -lt edits.sql -rw-r--r--1 will serensof 1280 Dec 28 22:23 edits.sql % ls -lu edits.sql -rw-r--r--1 will serensof 1280 Dec 28 23:06 edits.sql % grep xyz edits.sql % ls -lt edits.sql -rw-r--r--1 will serensof 1280 Dec 28 22:23 edits.sql % ls -lu edits.sql -rw-r--r--1 will serensof 1280 Jan 2 02:12 edits.sql % look under "man ls" for "-t" and for "-u" (and if you're bored and can figure out what 'file status information' pertains to, "-c"). -- See, if you were allowed to keep the money, you wouldn't create jobs with it. You'd throw it in the bushes or something. But the government will spend it, thereby creating jobs. -- Dave Barry [EMAIL PROTECTED]***http://www.dontUthink.com/ volunteer to document your experience for next week's newbies -- http://www.eGroups.com/messages/newbieDoc
Re: how to grep without changing timestamps?
on Sun, Dec 31, 2000 at 02:04:57PM -0500, Maciej Kalisiak ([EMAIL PROTECTED]) wrote: > Hello all, > > Is it possible to grep a ton of files without modifying their > date/timestamps? Currently if I use grep, it changes the access time > of all files touched, which causes mutt to lose track of the folders > which have new mail (I guess it looks at the timestamp last modified > and last accessed to figure this out). Occasionally I do want to > include the mail folders in my greps, so bypassing the "mail" > directory is not a solution. Several hacks come to mind: - Copy the files and grep the copies (does this change the timestamps?) - Remount the partition read-only. - Build a tool to check timestamps, save them, grep the files, then reapply the timestamps with 'touch'. Cheers. -- Karsten M. Self http://kmself.home.netcom.com/ Evangelist, Zelerate, Inc. http://www.zelerate.org What part of "Gestalt" don't you understand? There is no K5 cabal http://gestalt-system.sourceforge.net/http://www.kuro5hin.org pgpWqNm0XSzF3.pgp Description: PGP signature
Re: how to grep without changing timestamps?
On Sun, Dec 31, 2000 at 02:04:57PM -0500, Maciej Kalisiak wrote: > Hello all, > > Is it possible to grep a ton of files without modifying their date/timestamps? > Currently if I use grep, it changes the access time of all files touched, > which causes mutt to lose track of the folders which have new mail (I guess it > looks at the timestamp last modified and last accessed to figure this out). > Occasionally I do want to include the mail folders in my greps, so bypassing > the "mail" directory is not a solution. I doubt it. The point of the timestamps are to be accurate. However, you might be able to hack the inode afterwards, not that I'd recommend it. Mike -- Michael P. Soulier <[EMAIL PROTECTED]> "...the word HACK is used as a verb to indicate a massive amount of nerd-like effort." -Harley Hahn, A Student's Guide to UNIX PGP Public Key: http://www.storm.ca/~msoulier/email.phtml pgpHi4YZ3YZOE.pgp Description: PGP signature
how to grep without changing timestamps?
Hello all, Is it possible to grep a ton of files without modifying their date/timestamps? Currently if I use grep, it changes the access time of all files touched, which causes mutt to lose track of the folders which have new mail (I guess it looks at the timestamp last modified and last accessed to figure this out). Occasionally I do want to include the mail folders in my greps, so bypassing the "mail" directory is not a solution. -- Maciej Kalisiak [EMAIL PROTECTED] www.dgp.toronto.edu/~mac