From: sreservoir on 16 Feb 2010 13:46 On 2/16/2010 10:29 AM, Jarmo wrote: > I have a problem and I was hoping someone could help me. I have a program > that every time it runs it saves a log file with same name about the changes > it did on that particular run. Result is that old file gets overwritten and > lost. I would like to create "virtual file" so that every time foobar.log is > written I actually end up with a file that has date and time added to it. > > In other words: > I run application that writes to "foobar.log" and I want the file actually > go to "~/foobarlogs/foobarYYYY-MM-DD-HH-MM-SS.log" instead. > > I know I did something similar years ago with perl but my > programming/scripting skills are too rusty to accomplish it anymore on my > own. I would greatly appreciate the help. strftime("~/foobarlogs/foobar%Y-%m-%d-%H-%M-%S.log", gmtime); though I doubt what you want is a directory named ~. -- "Six by nine. Forty two." "That's it. That's all there is." "I always thought something was fundamentally wrong with the universe"
From: Frank Seitz on 16 Feb 2010 14:09 J�rgen Exner wrote: > Jarmo <jampe(a)darkbusstop.com> wrote: >> I have a problem and I was hoping someone could help me. I have a program >> that every time it runs it saves a log file with same name about the changes >> it did on that particular run. Result is that old file gets overwritten and >> lost. I would like to create "virtual file" so that every time foobar.log is >> written I actually end up with a file that has date and time added to it. >> >> In other words: >> I run application that writes to "foobar.log" and I want the file actually >> go to "~/foobarlogs/foobarYYYY-MM-DD-HH-MM-SS.log" instead. > > Not a Perl solution but what about running a cron job at midnight which > does a > ln -s foobar.log foobar[whateverthenewdayis] A symlink is obviously not a solution, because the file gets overwritten with every run. Frank -- Dipl.-Inform. Frank Seitz Anwendungen f�r Ihr Internet und Intranet Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel Blog: http://www.fseitz.de/blog XING-Profil: http://www.xing.com/profile/Frank_Seitz2
From: Helmut Richter on 16 Feb 2010 14:16 On Tue, 16 Feb 2010, Frank Seitz wrote: > > ln -s foobar.log foobar[whateverthenewdayis] > > A symlink is obviously not a solution, because the file > gets overwritten with every run. The other way would work: Every night: rm foobar.log ln -s foobar[whateverthenewdayis] foobar.log -- Helmut Richter
From: ccc31807 on 16 Feb 2010 14:29 On Feb 16, 1:27 pm, "Uri Guttman" <u...(a)StemSystems.com> wrote: > > GACK!! please use POSIX::strftime. i hate seeing hand made date > formatting. all you need is in that one sub and with less cruft and > noise and chance for errors. I have to create these kinds of file names and directory names in just about every script I write, so I wrote a utility library to make it easy. It's not any cruft, at least not in the executable script, but I wasn't aware that POSIX::strftime existed. I'll try it and see if it's any easier. Thanks for the pointer. CC.
From: Uri Guttman on 16 Feb 2010 14:31 >>>>> "c" == ccc31807 <cartercc(a)gmail.com> writes: c> On Feb 16, 1:27�pm, "Uri Guttman" <u...(a)StemSystems.com> wrote: >> >> GACK!! please use POSIX::strftime. i hate seeing hand made date >> formatting. all you need is in that one sub and with less cruft and >> noise and chance for errors. c> I have to create these kinds of file names and directory names in just c> about every script I write, so I wrote a utility library to make it c> easy. It's not any cruft, at least not in the executable script, but I c> wasn't aware that POSIX::strftime existed. I'll try it and see if it's c> any easier. Thanks for the pointer. it has to be easier as it already supports all the common date/time formats and parts you want. it requires no temp variables, no need to mung the values (+1900, etc), and it is stable. you can change the format easily unlike a hand written version. uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: readdir: is there a way to reset cursor to beginning? Next: FAQ 3.9 Is there a ctags for Perl? |