Skip to main content.
home | support | download

Back to List Archive

Re: configuring and debugging swish.cgi with IIS

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Thu Jun 12 2003 - 02:35:43 GMT
On Wed, Jun 11, 2003 at 06:19:52PM -0700, Nathan Vonnahme wrote:
> 
> Ahah!  I think I have confirmed that IPC::Open2 does not use the
> shell.  And my original post to the list specifying the quotes around
> "Program Files" appears to not really be necessary after all...  I
> don't know what my problem was the other day, and I'm sorry if I've
> caused anybody grief or alarm!

> 
> 	# using the shell, chokes on space
> 	$pid = open2($rdrfh, $wtrfh, 'C:\Program Files\SWISH-E\swish-e.exe -w foo');
> 	print scalar <$rdrfh>, '-'x50, "\n";
> 	# using the shell, properly escaped
> 	$pid = open2($rdrfh, $wtrfh, 'C:\"Program Files"\SWISH-E\swish-e.exe -w foo');
> 	print scalar <$rdrfh>, '-'x50, "\n";
> 	# without using the shell
> 	$pid = open2($rdrfh, $wtrfh, 'C:\Program Files\SWISH-E\swish-e.exe', "-w", "foo");
> 	print scalar <$rdrfh>, '-'x50, "\n";
> 
> produces this output:
> 	'C:\Program' is not recognized as an internal or external command,
> 	operable program or batch file.
> 	--------------------------------------------------
> 	# SWISH format: 2.2.3
> 	--------------------------------------------------
> 	# SWISH format: 2.2.3
> 	--------------------------------------------------
> 
> So, swish.cgi using open2 should be avoiding the shell.

My memory is slowing coming back.

If you look in swish.cgi you will see this bit:

    # Ok, I'll say it.  Windows sucks.
    my @command = map { s/"/\\"/g; $_ }  $self->{prog}, $self->swish_command_array;
    my $pid = IPC::Open2::open2($rdrfh, $wtrfh, @command );

Now, I wish I had added a better comment.  But I think why that map is
in there is to escape the quotes used in phrase searches.  That would
indicate to me that the call is going through the shell.  Let me try...

Ok, it took four reboots but I got my old windows machine to boot and 
look at this:


C:\WINDOWS\Desktop>cat test.pl
use IPC::Open2;
$pid = open2( $rdrfh, $wtrfh,
      'e:\Program Files\SWISH-E2.2\swish-e.exe',
      '-H9', '-w', 'foo "bar baz"' );
print while <$rdrfh>;


C:\WINDOWS\Desktop>perl test.pl
# SWISH format: 2.2.1
# Search words: foo bar baz
                   ^^^^^^^^ 
Hey! were are the quotes?!?  Looks like the shell (or something) ate 
them.

# Search Words: foo bar baz
# Parsed Words: foo bar baz

Yep, something ate the quotes.  If you backslash them then they make it 
through to swish-e.

That's on Win98 and Perl 5.6.1.

Now try the same thing on Linux:

moseley@bumby:~$ cat t.pl
use IPC::Open2;
$pid = open2( $rdrfh, $wtrfh,
      'swish-e',
      '-H9', '-w', 'foo "bar baz"' );
print while <$rdrfh>;

moseley@bumby:~$ perl t.pl | grep "Search words"
# Search words: foo "bar baz"
# Search words: foo "bar baz"

That's much better.  No doubt that's exactly what I went through before
that prompted that comment in swish.cgi...


-- 
Bill Moseley
moseley@hank.org
Received on Thu Jun 12 02:35:53 2003