Skip to main content.
home | support | download

Back to List Archive

Using - problems with open2 in Win 2000

From: <Allan_Watts(at)>
Date: Mon Jan 19 2004 - 01:37:29 GMT

I am trying to filter MS Word documents using (in order to use
the -S prog option when indexing). I am in a Windows 2000 enviroment...
(The perl script  I am using is below.)

All works fine for the first 64 files.  Then for the 65th file I get this

"Problems with filter 'SWISH::Filters::Doc2txt= HASH(0x1cb9a3c)]. Filter
-> open2: IO::Pipe: Can't spawn-NOWAIT: Resource temporarily unavailble at
c:/Program Files/SWISH-E/lib/swish-e/perl/SWISH/ line 1162

I tried to isolate the problem cutting down everything to:

#!c:\perl\bin\perl.exe -w
use strict;
use warnings;
use IPC::Open2;

my $rdrfh;
my $wtrfh;
for (my $i = 1 ; $i < 68; $i++)
      my $command = "c:\\WINNT\\catdoc.exe c:/data/swish/test/doc$i.doc";
      print "$command\n";
      my $pid = IPC::Open2::open2($rdrfh, $wtrfh, "$command" );
      #waitpid $pid,0;
      binmode $rdrfh, ':crlf';
      $/ = undef;
      my $content =  <$rdrfh>;
      print "$content" if $i > 60;

This reproduced the open2 error message.  The documentation around open2
mentions using waitpid - which I tried...   This fixed the problem in my
cut-down script.

But even after I added waitpid to, just after the call to open2,
I still got the same problem.

I am just learning perl - don't really know what I am doing... so chances
are I have done something stupid...

Any help would be appreciated!


This is my original script..

#!c:\perl\bin\perl.exe  -w
use strict;
use File::Find;
use lib 'c:/Program Files/SWISH-E/lib/swish-e/perl';


my $dir = shift || 'c:/data/swish/test';

my $filter;

            wanted => \&wanted,
            no_chdir => 1,

sub wanted
      return unless -f;

      # Load the Filter and call it on the file

      unless ( $filter ) {
            eval { require SWISH::Filter };
            if ( $@ ) {
                  print STDERR "Can't find SWISH::Filter.  Errorr message
is: $@";
            $filter = SWISH::Filter->new;
            unless ( $filter ) {
                  print STDERR "Can't create new Filter object with
SWISH::Filter->new. Errorr message is: $@";

      my $filename = $File::Find::name;
      my $doc = $filter->convert( document => $filename );

      # Skip if the file wasn't filtered or can't be indexed

      return unless $doc;
      return if $doc->is_binary;
      return unless $doc->content_type;   # Only index if if
$filter->convert has discovered a way Swish can index

      my $mtime  = (stat $filename)[9];
      my $doc_ref = $doc->fetch_doc;
      my $size = length $$doc_ref;
      my $doc_type = $doc->swish_parser_type;

      # Print Swish headers, and then print the document

      print <<EOF;

Content-Length: $size
Last-Mtime: $mtime
Document-Type: $doc_type
Path-Name: $filename


      print $$doc_ref;

This email message and any accompanying attachments may contain
information that is confidential and is subject to legal privilege. If you are not
the intended recipient, do not read, use, disseminate, distribute or copy this 
message or attachments. If you have received this message in error, please 
notify the sender immediately and delete this message. Any views expressed
in this message are those of the individual sender, except where the sender
expressly, and with authority, states them to be the views of AMP. Before 
opening any attachments, please check them for viruses and defects.
Received on Mon Jan 19 01:37:43 2004