Perl on Windows
Feb. 5th, 2006 01:20 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
This is partly just as a note to myself so I remember what I did.
The problem is that I keep forgetting what day and/or date it is, so I wanted a program that would provide a better clock display than the built-in one, ie. one that showed the correct day and date without my having to go look for it. Ideally, of course, I want it to be a proper updating clock, but a cron job that pops up a window saying 'Today is Saturday the 5th of February' for me to see when I got up in the morning would do just fine too, and require less immediate programming.
(Note that I have never done any Windows programming, and would really rather have kept it that way.) ActivePerl, however, beckoned, so I downloaded it and started playing with Tk. In short order, I had a script that popped up a window displaying the date & time. Took me ages, however, to find out how to stop it needing a DOS shell behind it. On Unix, of course, it's purely simple, you just use scriptname & and it forks off a process. It seems to be something basic in Windows, though, which thinks "Aha! Command line program, I shall helpfully provide a command line shell and if said command line shell is destroyed I shall destroy the program we wanted in the first place too!"
The answer, apparently - found as so many good things are via Usenet, in this case the archives of comp.lang.perl.tk - is to fool Windows into thinking it's a GUI program. Which is accomplished by running it from wperl.exe rather than perl.exe, it seems. Reassociate the file extension yet again...
However, does Windows do cron? Apparently not natively, and not in any useful sense. I picked up a Perl module going by the name of CRONw, which claims to be a "Windows service", whatever that means in practical terms. However, it didn't work. At all. Well, actually, it did spawn the process and leave it running, it just didn't point the window at the desktop, and happily pretended everything was fine. Couldn't find a way to fix that, so I lost my temper and deleted it with extreme prejudice. Let's see what happens the next time I try to find a way to do this.
The problem is that I keep forgetting what day and/or date it is, so I wanted a program that would provide a better clock display than the built-in one, ie. one that showed the correct day and date without my having to go look for it. Ideally, of course, I want it to be a proper updating clock, but a cron job that pops up a window saying 'Today is Saturday the 5th of February' for me to see when I got up in the morning would do just fine too, and require less immediate programming.
(Note that I have never done any Windows programming, and would really rather have kept it that way.) ActivePerl, however, beckoned, so I downloaded it and started playing with Tk. In short order, I had a script that popped up a window displaying the date & time. Took me ages, however, to find out how to stop it needing a DOS shell behind it. On Unix, of course, it's purely simple, you just use scriptname & and it forks off a process. It seems to be something basic in Windows, though, which thinks "Aha! Command line program, I shall helpfully provide a command line shell and if said command line shell is destroyed I shall destroy the program we wanted in the first place too!"
The answer, apparently - found as so many good things are via Usenet, in this case the archives of comp.lang.perl.tk - is to fool Windows into thinking it's a GUI program. Which is accomplished by running it from wperl.exe rather than perl.exe, it seems. Reassociate the file extension yet again...
However, does Windows do cron? Apparently not natively, and not in any useful sense. I picked up a Perl module going by the name of CRONw, which claims to be a "Windows service", whatever that means in practical terms. However, it didn't work. At all. Well, actually, it did spawn the process and leave it running, it just didn't point the window at the desktop, and happily pretended everything was fine. Couldn't find a way to fix that, so I lost my temper and deleted it with extreme prejudice. Let's see what happens the next time I try to find a way to do this.