This question about Using an extension: Answered but needs rewriting

DOC_antiword.pm has a problem with hosted webserver

Extensive debugging in IRC with MTempest has shown that the antiword program (to index DOC files) is called from DOC_antiword.pm in a way which gives an error on a hosted webserver.

Although all other handlers indexed OK, DOCs wouldn't at all.

Debugging showed the following message being returned from Antiword when called from the indexing routine:-

"I can't find the name of your HOME directory I can't open your mapping file (8859-1.txt) It is not in '/.antiword' nor in '/usr/share/antiword'. "

From the IRC chat:----

<MTempest> Antiword looks for its mapping files in three directories, in the order given:
<MTempest> (1) The directory specified by $ANTIWORDHOME
<MTempest> (2) The directory specified by $HOME/.antiword
<MTempest> (3) Directory /usr/share/antiword
<MTempest> Ideally, you need to set the ANTIWORDHOME environment variable when running antiword.

On a hosted server if antiword is not installed in the main server, it will require installation by each user into their home directrory (e.g. /home/mydomain/.antiword and /home/mydomain/bin), not the root directory of the server. Without the $ANTIWORDHOME being available/passed to antiword from the DOC_antiword.pm, the program fails and returns an empty string as the indexed value.

MTempest instructed me to change the line highlighted above to at least get antiword running in my environment:

my $output = "".`ANTIWORDHOME=/home/mydomain/.antiword $antiword $file 2>&1`;
my $exit = 0;

This now works as expected on the hosted server. However, there must be a more robust method in using the SYSCommand calling method to pass the $ANTIWORDHOME parameter in the environment.
The environment of the calling process is passed on to any subprocess invoked by any of the methods used in Sandbox.pm. So, you have a couple of choices:

  1. $ENV{ANTIWORDHOME}='/home/mydomain/.antiword'; somewhere in the perl
  2. Use Apache mod_env to set the environment variable
I don't know if this is intended to be portable, but on a linux server I would personally use the approach suggested by Michael, but I would pass in the value of $cmd from a configuration variable e.g. $Foswiki::cfg{Extensions}{KinoSearchContrib}{AntiwordCommand} = '...'

-- CrawfordCurrie - 06 Sep 2010

This needs updating for the latest version of Stringifier Plugin. THe above instructions do not apply to the latest DOC_antiword.pm file.

-- BobCorless - 12 Nov 2010

Afaict, the new DOC_antiword.pm implemented CDot's suggestion, so you should be able to do it via configure, in the Extensions tab, in StringifierContrig, you should have a setting called antiwordCmd. Simply update that to have /usr/bin/env ANTIWORDHOME=/home/mydomain/.antiword .... The ... being the part that's already there, which should be the path to your antiword.

-- OlivierRaginel - 12 Nov 2010

QuestionForm edit

Subject Using an extension
Extension KinoSearchContrib
Version Foswiki 1.1.1
Status Answered but needs rewriting
Topic revision: r6 - 12 Nov 2010, OlivierRaginel
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy