For windows try this

sub executeTool($){
    my ($toolPath) = @_;
    my $comspec = $ENV{'COMSPEC'}; # Get the path to the command line
interpriter if this ENV var is not available in your system you will need to
hard code this part

    open(TOOL, "$comspec /c $toolPath|");
    my $result = <TOOL>;     # you will need to put this in a loop if the
too gives multiple lines of output
    close(TOOL);
    return $result;
}

if your too going to give multiple lines of out put you will need to make
some small changes






LRMK
----- Original Message ----- 
From: "Randy W. Sims" <[EMAIL PROTECTED]>
To: "perl.org" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, June 23, 2004 3:59 PM
Subject: Re: open CONSOLE?


> perl.org wrote:
> > Hi,
> >
> > Is there a way to explicitly open a handle to the "console", or wherever
> > STDOUT/STDERR are directed to by default?
> >
> > My process is running in an environment in which STDOUT and STDERR have
> > already been redirected.  I want to intercept these streams when running
> > command line tools, then restore them afterwards.  I want to be able to
call
> > my command line tool like:
> >
> > my ${ret} = `command 2>&1`;
> >
> > and have ${ret} get the both STDOUT and STDERR.  This piece gets called
a lot
> > so I want to avoid temp files if I can.  This has to work on Windows if
that
> > makes any difference (I think that means no /dev/console, etc.).  I know
> > about:
> >
> > open( RESTORESTDOUT, '>>&STDOUT' );
> >
> > and I think I can restore the redirected STDOUT from there, but how to I
open
> > STDOUT so that it goes to the "console", as if it had never been
redirected?
> >
> > Hopefully this makes some sense.
>
> open( OUT, 'con' ); # IIRC
>
> I /think/ you can also use POSIX::fdopen() or IO::Handle::new_from_fd()
> to get the standard streams.
>
> Randy.
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to