Re: Launch an indexing with parameters from a PHP page?

Peter Karman <[email protected]> Wed, 6 Sep 2006 06:23:50 -0700 (PDT)
Newsgroups gmane.comp.web.swish-e
Message-ID <[email protected]>

François Tissandier scribbled on 9/4/06 4:08 AM:

> 
> "file.php ID=12345 | swish-e -c config.file -S prog -i stdin"
> 
> which works ... but only from the command line.
> 
> When I try to run this command from an "exec(....)" in PHP, it doesn't
> work, it seems that the swish-e command doesn't read the result of
> file.php, but something different (the page calling the command?). I'm
> quite a newbie with Linux, so now I'm stuck with this error.
> 
> Maybe there is another solution, but that's the one I thought about. I
> just want to be able to run an indexing with some parameters from a
> website. Thanks in advance if you have some advices...
> 

could you just make the index.php page write a little shell script to call the 
command, and then let cron run it for you?

index.php writes to a tmp file somewhere:

#!/bin/sh

path/to/file.php ID=12345 | swish-e -c config.file -S prog -i stdin \
     && echo "indexing done"

and then exec that tmp file via cron. See the cron man pages.

However, I'd be worried about security issues in exec() from the web. Untainting 
input etc.

This seems like a "how do I exec a command via PHP" question more than a swish-e 
question.

-- 
Peter Karman  .  http://peknet.com/  .  [email protected]