From nate at campi.cc Sun Dec 2 13:23:19 2001 From: nate at campi.cc (Nate Campi) Date: Thu Aug 5 00:02:53 2004 Subject: [JaxPM] dynamic external program output from long-running perl program Message-ID: <20011202112319.H9104@campin.net> On the jacksonville-pm-list; Jax.PM'er Nate Campi wrote - I have a long-running perl program that I want to use to capture the output of different (UNIX) system commands. This is actually a perl module for AOL Intant Messenger (found it on CPAN). I'd eventually like to be able to query our monitoring system for the current and last alerts via AIM. I'll probably supplement our current email/pager alerts with AIM alerts, too (but that's another script ;) The problem is that any program output is gathered at compile time once, or if using eval at run time only once. For testing I want to get the current output of `date`, and I'll know it's working. Anyone know of a way I can do what I want here? For security reasons I'll have to take a hard look at if I really want to deploy this, but either way it's fun to play with. -- Nate Campi http://www.campin.net GnuPG key: 0xC17AEF79 Key fingerprint = BF12 722F 8799 E614 33CC FAB7 5A90 C464 C17A EF79 "I've not lost my mind. It's backed up on tape somewhere." - Unknown Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From nate at campi.cc Sun Dec 2 17:36:29 2001 From: nate at campi.cc (Nate Campi) Date: Thu Aug 5 00:02:53 2004 Subject: [JaxPM] dynamic external program output from long-running perl program In-Reply-To: <20011202112319.H9104@campin.net>; from nate@campi.cc on Sun, Dec 02, 2001 at 11:23:19AM -0800 References: <20011202112319.H9104@campin.net> Message-ID: <20011202153629.J9104@campin.net> On the jacksonville-pm-list; Jax.PM'er Nate Campi wrote - begin Nate Campi quotation of Sun, Dec 02, 2001 at 11:23:19AM -0800: > On the jacksonville-pm-list; Jax.PM'er Nate Campi wrote - > > I have a long-running perl program that I want to use to capture the > output of different (UNIX) system commands. This is actually a perl > module for AOL Intant Messenger (found it on CPAN). I'd eventually > like to be able to query our monitoring system for the current and > last alerts via AIM. I'll probably supplement our current email/pager > alerts with AIM alerts, too (but that's another script ;) > > The problem is that any program output is gathered at compile time once, > or if using eval at run time only once. For testing I want to get the > current output of `date`, and I'll know it's working. > > Anyone know of a way I can do what I want here? I ended up working this out, thanks anyways. -- Nate Campi http://www.campin.net GnuPG key: 0xC17AEF79 Key fingerprint = BF12 722F 8799 E614 33CC FAB7 5A90 C464 C17A EF79 So unleash your nmap-from-hell and beware, you may tickle an obscure bug in an ancient box hand-built by Seymour Cray himself, the only one of its kind ever made, whose sole user pays the salaries of everyone you ever met in the entire time you worked at the company, with money he makes with an investment strategy hand-coded in assembler for this special machine, by an analytic wizard who has since died. Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From nate at campin.net Sat Dec 29 19:11:40 2001 From: nate at campin.net (Nate Campi) Date: Thu Aug 5 00:02:53 2004 Subject: [JaxPM] autoflush Message-ID: <20011229171140.B6121@campin.net> On the jacksonville-pm-list; Jax.PM'er Nate Campi wrote - I've been getting weird results with trying to turn on autoflushing for filehandles. Can I just set "$| = 1;" once at the top of the script to affect all filehandles or do I have to "select" a filehandle then set the "$|" variable? This is obviously when not using the object-oriented IO::Handle. TIA -- Nate Campi http://www.campin.net GnuPG key: 0xC17AEF79 The probability of someone watching you is proportional to the stupidity of your action. Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From sneex at mac.com Sat Dec 29 19:18:53 2001 From: sneex at mac.com (Bill Jones) Date: Thu Aug 5 00:02:53 2004 Subject: [JaxPM] autoflush In-Reply-To: <20011229171140.B6121@campin.net> Message-ID: <303FFB0E-FCC3-11D5-BFE3-0003930CAF62@mac.com> On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - Prior to 5.004 you had to select each handle; but a simple #!perl -Tw $|++; should work. Selecting handle is a sure fire way, if you want to be sure... HTH; -Sx- :] On Saturday, December 29, 2001, at 08:11 PM, Nate Campi wrote: > I've been getting weird results with trying to turn on autoflushing for > filehandles. Can I just set "$| = 1;" once at the top of the script to > Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From greg at turnstep.com Sun Dec 30 12:13:26 2001 From: greg at turnstep.com (Greg Sabino Mullane) Date: Thu Aug 5 00:02:53 2004 Subject: [JaxPM] autoflush Message-ID: On the jacksonville-pm-list; Jax.PM'er "Greg Sabino Mullane" wrote - -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > I've been getting weird results with trying to turn on > autoflushing for filehandles. Can I just set "$| = 1;" once at > the top of the script to affect all filehandles or do I have > to "select" a filehandle then set the "$|" variable? You have to set it for each one: $| only affects the currently selected filehandle. One easy way to do this is like this: select((select(FOO),$|=1)[0]); which temporarily selects the filehandle "FOO", sets autoflushing on, and then selects back into the previous filehandle. I use this a lot. Someday perl will have an "autoflush by default" which would be really, really nice. It's the default in IO::Handle module, but not when doing it yourself. All of this is covered in perlfaq5, first question, by the way. Try 'perldoc -q flush' to jump to it from a command prompt. Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200112301301 -----BEGIN PGP SIGNATURE----- Comment: http://www.turnstep.com/pgp.html iQA/AwUBPC9YZ7ybkGcUlkrIEQLs3QCg5xH4/ROOtWxnnPeSoHhF4qz+m0wAoJLj 579rjLwYlQ7hNQnTsS4imjGE =dtfL -----END PGP SIGNATURE----- Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From sneex at mac.com Sun Dec 30 12:43:16 2001 From: sneex at mac.com (Bill Jones) Date: Thu Aug 5 00:02:53 2004 Subject: [JaxPM] autoflush In-Reply-To: Message-ID: <16285AD4-FD55-11D5-A764-0003930CAF62@mac.com> On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - Mea Culpa :/ http://www.perldoc.com/perl5.6.1/pod/perlfaq5.html#How-do-I-flush-unbuffer-an-output-filehandle---Why-must-I-do-this- I had mistakenly thought this was resolved to cause $|++; to auto-flush when either the Output Handle was closed (or better) when there was CGI data waiting... Wait ... Isn't $|++ set to *prevent* buffering when using CGI file handles? ???/Sx :] On Sunday, December 30, 2001, at 01:13 PM, Greg Sabino Mullane wrote: > On the jacksonville-pm-list; Jax.PM'er "Greg Sabino Mullane" > wrote - > select((select(FOO),$|=1)[0]); Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments...