RE: Pipe and redirect STDOUT

2004-02-23 Thread Kevin Hill

Guys,

My understanding is that there is a bug in the file extension/application to execute 
code, that is part of windows, that stops redirection from working if Microsoft does 
this "lookup" itself. Stopping it having to do this lookup, by invoking Perl.exe 
directly, gets around this issue. This problem has been around for as long as I can 
remember.

Kev.



-Original Message-
From: Martin Leese [mailto:[EMAIL PROTECTED]
Sent: 23 February 2004 05:05 pm
To: [EMAIL PROTECTED]
Subject: Re: Pipe and redirect STDOUT


Sui Ming Louie wrote:
> I have run similar batch files on NT4.0.  They worked OK.  At one point, I
> used to think that redirection from batch files was not possible.  Then I
> got some insight from reading the perl2bat.bat file included with Perl.

I asked the original question, so I thought I would try to
summarize progress to date.

First, many thanks to everyone who has responded.  One
poster suggested the problem might be that typing "test.pl"
invoked a BAT file, and that my problem was redirection
from BAT files in general.

There is no "perl.bat" on my system, so this is not the
problem.  Also, redirection from BAT files appears to work
as expected.  (Also, also, there is no "perl2bat.bat" file
on my system.)

Another poster suggested trying "perl test.pl" and, indeed,
redirection using this form of invocation works fine.  This
is a valid work around and, although my problem has not
been solved, my problem is no longer a problem.

> Martin Leese wrote:
>>Hi,
>>
>>I know this is a really dumb question (yes, there are dumb
>>questions), but I am stuck.
>>
>>Why can I neither pipe the output from a perl script to "more"
>>nor redirect it to a file?  This is under Windows NT.
>>
>>The following script:
>>
>>#! /usr/local/bin/perl
>>#
>>use strict;
>>use warnings;
>>###use diagnostics;
>>#
>>print STDOUT "Hello me";
>>#
>>exit(0);
>>
>>produces "Hello me" on the screen with the command "test.pl".
>>However, the command "test.pl |more" produces a blank line,
>>and the command "test.pl >test.txt" produces an empty file.
>>Why?
>>
>>As the more intelligent amongst you will have guessed, I am
>>not a Windows person.
>>
>>Also, while you are here, what is the difference between
>>"use warnings;" and "use diagnostics;"?
>>
>>I am running perl, v5.8.2 built for MSWin32-x86-multi-thread,
>>Binary build 808 provided by ActiveState Corp. under
>>Windows NT.
>>
>>Many thanks for any help you can give.
>>
>>Regards,
>>Martin

Thanks again to everyone who responded,
Martin


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden. TradeWeb reserves 
the right to monitor all e-mail communications through its networks.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Wierd Perl syntax ($#$dlr) explanation, please!

2003-11-21 Thread Kevin Hill

Dietmar,

Thanks for the response. I read that in the manual but it didn't make sense to me in 
the way that this was being used. There is a loop and, within it, the following:

next if ($#$dlr == -1);

How would the awk-stuff below fit with this code above?

Ta.
K.

Kevin Hill
AVP Programmer
 
TradeWeb Europe Ltd 
99 Gresham Street
London EC2V 7NG
Tel:  +44 (0)20 7776 3200
Fax: +44 (0)20 7776 3201
www.tradeweb.com




-Original Message-
From: Dietmar Maurer [mailto:[EMAIL PROTECTED]
Sent: 21 November 2003 11:33 am
To: Kevin Hill
Subject: AW: Wierd Perl syntax ($#$dlr) explanation, please!


>From perlvar:

$#

The output format for printed numbers. This variable is a half-hearted
attempt to emulate awk's OFMT variable. There are times, however, when awk
and Perl have differing notions of what counts as numeric. The initial value
is ``%.ng'', where n is the value of the macro DBL_DIG from your system's
float.h. This is different from awk's default OFMT setting of ``%.6g'', so
you need to set $# explicitly to get awk's value. (Mnemonic: # is the number
sign.)
Use of $# is deprecated.


So $#$dlr is $# followed by $dlr.

Dietmar

> -Ursprüngliche Nachricht-
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Auftrag von
> Kevin Hill
> Gesendet: Freitag, 21. November 2003 12:12
> An: Active Perl Mailgroup (E-mail); Perl Win32 Users (E-mail)
> Betreff: Wierd Perl syntax ($#$dlr) explanation, please!
>
>
>
> Guys,
>
> Just found this in some of our legacy Perl code - any idea what
> it does? $dlr is a scalar, containing the name of a dealer.
>
>   $#$dlr
>
> Thanks for any help that can be given.
>
> Kev.
>
> Kevin Hill
> AVP Programmer
>
> TradeWeb Europe Ltd
> 99 Gresham Street
> London EC2V 7NG
> Tel:  +44 (0)20 7776 3200
> Fax: +44 (0)20 7776 3201
> www.tradeweb.com
>
>
>
> 
>
> This e-mail may contain confidential and/or privileged
> information. If you are not the intended recipient (or have
> received this e-mail in error) please notify the sender
> immediately and destroy this e-mail. Any unauthorized copying,
> disclosure or distribution of the material in this e-mail is
> strictly forbidden. TradeWeb reserves the right to monitor all
> e-mail communications through its networks.
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Fork/wait generating GPF at 0x0000000c in Perl.exe

2003-11-12 Thread Kevin Hill

Guys,

I am running ActiveState Perl v5.8.0 straight out of the box, with the following test 
piece of code for forking and waiting for child processes. Perl.exe generates a GPF at 
0x000c as the child is quitting. Anyone have any ideas what might be going wrong? 
I based the code on the code extract within the fork documentation in the Camel book.

The output up until just before the GPF is as follows:

Parent. Child is -108
Child: started: -108
Parent waiting for kiddies...
Child: -108 about to exit.

Sorry if this topic has already been done to death, but I had a search and couldn't 
find anything that appeared relevant.

Ta.

Kev.


sub InvokeCmdAsAsyncProcess
{
my( $exec_line, $dummy ) = @_;
my $pid;

FORK:
{
if( $pid = fork ) {
# Parent process here.
# Child pid in $pid.
print "Parent. Child is $pid\n";
}
elsif( defined( $pid ) ) {
# Child process here.
# parent process pid is available with getppid
print "Child: started: $$\n";
sleep 10;
#system (1, "$exec_line");
print "Child: $$ about to exit.\n";
exit 0;
}
elsif( $! =~ /No more process/ ) {
# EAGAIN, supposedly recoverable fork error
print "Forking having problems. Retrying\n";
sleep 2;
redo FORK;
}
else
{
# Wierd fork error.
die "Can't fork: $!\n";
}
}

return $pid;
} # end of InvokeCmdAsAsyncProcess


my %pids;
my $pid;# pid of most recent child process.
foreach $filename (@files)
{
my $exec_line = "$filename > $filename.log";
print "Executing $exec_line\n";
$pid = InvokeCmdAsAsyncProcess( $exec_line );
if( defined( $pid ) ) {
$pids{$pid} = $pid;
}
}

print "Parent waiting for kiddies...\n";
while( ($pid = wait()) != -1 ) {
print "Parent: Child $pid exitted with status: $?\n";
}
print "Parent after wait.\n";




Kevin Hill
AVP Programmer
 
TradeWeb Europe Ltd 
99 Gresham Street
London EC2V 7NG
Tel:  +44 (0)20 7776 3200
Fax: +44 (0)20 7776 3201
www.tradeweb.com





This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden. TradeWeb reserves 
the right to monitor all e-mail communications through its networks.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs