Re: advanced stdout/stderr capturing?

2003-02-13 Thread David Wheeler
On Wednesday, February 12, 2003, at 11:43  PM, Nathan Herring wrote:


Is there something out there that already does this? Or does it on
arbitrary numbers of filehandles/io::handles?


You need to tie your STDERR and STDOUT file handles. Write a custom tie 
module and simply tie it to STDERR and STDOUT. Check out the TieOut.pm 
module in various modules on the CPAN for an example. I use a variation 
in my App::Info module for testing. It looks like this:

package TieOut;

# This module is swiped and adapted from ExtUtils::MakeMaker.

sub TIEHANDLE { bless [], ref $_[0] || $_[0] }

sub PRINT {
my $self = shift;
push @$self, join '', @_;
}

sub PRINTF {
my $self = shift;
push @$self, sprintf @_;
}

sub READLINE {
my $self = shift;
return shift @$self;
}

sub read {
my $self = shift;
my $ret = join '', @$self;
@$self = ();
return $ret;
}

1;

Then in my tests, I just have:

my $stdout = tie *STDOUT, 'TieOut' or die "Cannot tie STDOUT: $!\n";
my $stdin = tie *STDIN, 'TieOut' or die "Cannot tie STDIN: $!\n";

The upshot is that you can just rewrite the PRINT method to both print 
stuff to STDOUT and to log what was printed however you like. Use 
Time::HiRes for sub-second times.

HTH,

David

--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED]  ICQ: 15726394
   Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]



Apache Build Update

2003-02-13 Thread David Wheeler
Howdy,

I've written an update to my "compile your own Apache" articles on 
MacDevCenter.com. The update documents how libapreq now supports 
Jaguar. This means that you can now use Apache::Request and 
Apache::Cookie on Jaguar without statically compiling libapreq into 
Apache. You can even use libapreq with Apple's Apache now. Mac OS X 
10.1.x users still have to patch Apache.

  http://www.macdevcenter.com/pub/a/mac/2003/02/07/libapreq_update.html

Enjoy,

David

--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED]  ICQ: 15726394
   Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]



Re: konfabulator -- something to ponder

2003-02-13 Thread Michael P . Wilson
Careful, neither is Konfabulator.

On Wednesday, Feb 12, 2003, at 22:28 America/New_York, Joel Rees wrote:


Shux, I just wish this had been Perl...


So, is this konfabulator thingy going to have some advantage over, say,
Tk with Perl?

(Or RealBASIC, or Borland's Java gadget, except that those are not 
free?)

--
Joel Rees <[EMAIL PROTECTED]>


-
"Thus nature has no love for solitude, and always leans, as it were, on 
some support; and the sweetest support is found in the most intimate 
friendship." - Cicero

http://radio.weblogs.com/0108194/



Re: (CB) Notification confusion

2003-02-13 Thread Sherm Pendley
On Thursday, February 13, 2003, at 03:49 AM, Rich Morin wrote:


What's the chance of your reworking your NSBrowser example into an
NSOutlineView example?


M'kay, then.

If you enter a new path into the edit box, the "root" of the outline 
view changes to that path.

Double-clicking on a folder in the outline view changes the "root" to 
that folder.

NSOutlineView appears to depend on the data objects passed to it being 
retained. Normally, any object that has this requirement simply issues 
the retains itself, and corresponding releases when its finished with 
the objects it needed. But, NSOutlineView doesn't do that; you have to 
explicitly retain the objects you pass to it. This presents a problem, 
because you can't retain NSString objects in CB right now, as they're 
automagically converted to and from Perl scalars. This magic conversion 
will be enhanced in CB 0.3, to allow for access to the native NSString 
objects, but for now the workaround is to use NSAttributedString objects 
instead.

For the most part, I used Cocoa's NSDictionary, NSArray, and 
NSFileManager objects in this sample, instead of Perl hashes, arrays, 
and opendir/readdir functions. I figured the Perl stuff already has more 
documentation than you can shake a camel at, so doing it the "Cocoa Way" 
would be more useful as an example.

I did, however, use Perl's file test operators and stat() function in a 
couple of places. I suppose that can serve as an example, too - it shows 
you can mix-n-match techniques as needed to suit your purpose. The truth 
of it, though, is that I got lazy, and two-letter file tests are much 
less verbose than NSFileManager methods... ;-)

Once again, this will be part of 0.3 when it's released, but for now you 
can download it from my site:



sherm--

Welcome to Rivendell, Mr. Anderson.



Re: advanced stdout/stderr capturing?

2003-02-13 Thread Daniel Stillwaggon

On Wednesday, Feb 12, 2003, at 21:17 US/Pacific, Rob Barris wrote:

I usually just write my scripts to log to a file, and then start up a  
separate Terminal window and say

tail -f logfile

But I only do that on stdout and dunno about getting stderr to go to  
the same place.
You can just 'open' STDERR to the same location.

Usually, if I have custom logging needs, I use custom routines (usually  
bail instead of die and whine instead of warn) that do whatever needs  
to be done.

 
-
Daniel C. Stillwaggon
([EMAIL PROTECTED])



Re: Fink sets PERL5LIB

2003-02-13 Thread Michael Maibaum
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On Thursday, February 13, 2003, at 08:08 AM, David R. Morrison wrote:




On Feb 13,2003 09:00:03 -0700, Nathan Torkington <[EMAIL PROTECTED]>  
wrote :
David R. Morrison writes:

The problem here is that Fink compiled Storable.pm under  
/usr/bin/perl,
which for most people would be the Apple-installed 5.6.0 version,  
and you
are now running a different perl version.

The trouble is that Apple (in their infinite wisdom and glory) have
removed the version number from the Perl library paths.  This is what
would let multiple versions of Perl coexist in peace.

So perhaps you should put the version number into Fink's Perl library
and change init.csh to do something like:

 PERL_VERSION=`perl -MConfig -e 'print $Config{version}'`
 PERL5LIB="/sw/lib/perl5/$PERL_VERSION"

Starting scripts with #!/usr/bin/perl5.6.0 will ensure the system
Perl is used.

Nat



Another strategy I thought of is to ask everybody who compiles their  
own
version of perl to do it "right" and to put the version number into the
library path.  In fact, Fred Sanchez submitted a patch for the darwin
configuration on perl, which I believe was accepted by the perl  
project, which
does exactly that.  (I'll rummage around and see if I can find that.)

What I'm hoping is that this patch tells perl to look in
$PERL5LIB/$PERL_VERSION.  If so, then the only unversioned stuff would  
be
stock Apple 5.6.0 (in principle), right?


as long as you set the Perl prefix to something "else" like /sw or  
/opt/local, Perl does the right thing with regard to versioning the  
perlib folders on OS X.

The configure args I use for perl are below (from my Portfile in  
darwinports <  
http://www.opendarwin.org/cgi-bin/cvsweb.cgi/proj/darwinports/dports/ 
lang/perl5.8/Portfile?rev=1.12&content-type=text/x-cvsweb-markup>)

 -des -Dinstallprefix='${destroot}/${prefix}' -Dprefix='${prefix}'   
- -Dccflags=-I'${prefix}/include' -Dldflags=L'${prefix}/lib  '


installprefix is so perl is installed in destroot for packaging,  
normally you can leave that out, prefix is the installation location  
(/opt/local by default here)

Michael
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (Darwin)

iD8DBQE+S804ilk3LUlIL0MRAq+/AJ9GUgdmwMU5hU57eWAZTDCuIiBxHgCfW1mW
PtXX/apqSvzB05ox+dCtrtA=
=1m1L
-END PGP SIGNATURE-



Re: Fink sets PERL5LIB

2003-02-13 Thread David R. Morrison


On Feb 13,2003 09:00:03 -0700, Nathan Torkington <[EMAIL PROTECTED]> wrote :
>David R. Morrison writes:
>> The problem here is that Fink compiled Storable.pm under /usr/bin/perl,
>> which for most people would be the Apple-installed 5.6.0 version, and you
>> are now running a different perl version.
>
>The trouble is that Apple (in their infinite wisdom and glory) have
>removed the version number from the Perl library paths.  This is what
>would let multiple versions of Perl coexist in peace.
>
>So perhaps you should put the version number into Fink's Perl library
>and change init.csh to do something like:
>
>  PERL_VERSION=`perl -MConfig -e 'print $Config{version}'`
>  PERL5LIB="/sw/lib/perl5/$PERL_VERSION"
>
>Starting scripts with #!/usr/bin/perl5.6.0 will ensure the system
>Perl is used.
>
>Nat
>

Another strategy I thought of is to ask everybody who compiles their own
version of perl to do it "right" and to put the version number into the
library path.  In fact, Fred Sanchez submitted a patch for the darwin
configuration on perl, which I believe was accepted by the perl project, which
does exactly that.  (I'll rummage around and see if I can find that.)

What I'm hoping is that this patch tells perl to look in
$PERL5LIB/$PERL_VERSION.  If so, then the only unversioned stuff would be
stock Apple 5.6.0 (in principle), right?

  -- Dave






Re: Fink sets PERL5LIB

2003-02-13 Thread Nathan Torkington
David R. Morrison writes:
> The problem here is that Fink compiled Storable.pm under /usr/bin/perl,
> which for most people would be the Apple-installed 5.6.0 version, and you
> are now running a different perl version.

The trouble is that Apple (in their infinite wisdom and glory) have
removed the version number from the Perl library paths.  This is what
would let multiple versions of Perl coexist in peace.

So perhaps you should put the version number into Fink's Perl library
and change init.csh to do something like:

  PERL_VERSION=`perl -MConfig -e 'print $Config{version}'`
  PERL5LIB="/sw/lib/perl5/$PERL_VERSION"

Starting scripts with #!/usr/bin/perl5.6.0 will ensure the system
Perl is used.

Nat




Re: advanced stdout/stderr capturing?

2003-02-13 Thread Andrew M. Langmead
On Wed, Feb 12, 2003 at 08:43:51PM -0800, Nathan Herring wrote:
> One of my desired goals is to replace STDERR and STDOUT in such a way
> that
> 1) the command line user still sees them both, and as they are output
> (not strangely buffered)
> 2) I have a log of every snippit of STDERR and STDOUT with the time (in
> granularity more fine than seconds, if possible) it arrived and in the
> order that it was received.

I would suggest to take a the IPC::Open3 module that comes with perl.
You pass it three filehandles, one for the program's standard input,
one for its standard output, and one for standard error.

To be able to read both filehandles simultaneously in order to report
their contents to the user, you might want to use the IO::Select to
determine when one of them has data ready.

This may or may not handle all of your requirements. The one last
aspect is the buffering. Using IPC::Open3 and select won't add any
additional buffering, but since the output of the external program is
no longer a terminal and is now a pipe, it will possibly acquire
stdio's standard buffering semantics and start block buffering
standard output. (I guess the idea that the designers of stdio had was
that programs run interactively needed immediate feedback. When output
was piped it could switch to a more efficient mode.) If you have
control of the external program, you might want to force it's standard
output to be unbuffered. If you don't, you might need to use something
like the CPAN module IO::Pty.



-- 
"Maybe I should be in Hollywood!"  -- Samantha Langmead, age 5. 
on learning how to use iMovie.




Re: (CB) Notification confusion

2003-02-13 Thread Rich Morin
At 1:10 AM -0500 2/13/03, Sherm Pendley wrote:

I've put together a sample app showing how to use NSBrowser with CB.


Very cute.  Although I don't want my browser to act quite the way yours
does, I was able to rework my (browser's) plumbing substantially, using
yours as a model.  You're quite right, BTW, I have LOTS of things other
than CB plumbing to work on; maybe now, I'll be able to get to them...

Thanks, Rich
--
email: [EMAIL PROTECTED]; phone: +1 650-873-7841
http://www.cfcl.com/rdm- my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc - Prime Time Freeware's Darwin Collection



Re: Fink sets PERL5LIB

2003-02-13 Thread Nathan Torkington
Nathan Torkington writes:
> If you use Fink to install something that has a Perl module component,
> Fink's /sw/bin/init.csh will set the PERL5LIB environment variable
> when you next log in.  This screws with @INC if you have your own Perl
> installed--you'll see Dylib messages everything you try to do
> something that involves a Perl module with an XS component.

In particular, I get this message:

 dyld: perl Undefined symbols:
 _Perl_safefree
 _Perl_safemalloc
 _Perl_saferealloc
 _Perl_sv_2pv
 _perl_call_sv
 _perl_eval_sv
 _perl_get_sv
 Trace/BPT trap

The only thing in /sw/lib/perl5 is a build of Storable.  I get the
coredump when I use CPAN.pm.  The fix is to unset PERL5LIB and take
the old-Perl Storable.pm out of my search path.

Nat