Command line tools for Dokuwiki

Dokuwiki Command Line Interface

Three CLI tools are:

  • dwpage.php
  • indexer.php
  • wantedpages.php

Indexer

To run this do the following:

cd /var/www/sub/wiki
/usr/bin/php bin/indexer.php -c
chown -R www-data:www-data *

Explanation:

  • Move to the dokuwiki root directory
  • Run command (make sure your php is where the script says it is)
  • The command does a clean and recreate index - which is the way I prefer
  • Make sure the permissions on the new index files are good by changing them to the apache user

Here is a full script

#!/bin/bash
cd /var/www/sub/wiki
/usr/bin/php bin/indexer.php -c
chown -R www-data:www-data *
exit

Wanted Pages

To run this do the following:

cd /var/www/sub/wiki
/usr/bin/php bin/wantedpages.php | grep -v "some:namespaces" | grep -v "wiki:nonexisting" | grep -v "wiki:pagename"

Explanation:

  • Move to the dokuwiki root directory
  • Run the command but ignore some outputs that I know are broken links and don't care to fix
  • If you get no output you are good to go
  • Otherwise to find the source file that is having the issue for each line of output run this command
    • grep -R “somenamespace:someothernamespace:somepage” data/pages/*
    • This will give you the source page having the broken link

Here is a full script that can be saved and run any time:

#!/bin/bash
NOW=$(date +"%Y-%m-%d-%H-%M-%S")
wpages=/tmp/blinks_${NOW}.txt
cd /var/www/sub/wiki
/usr/bin/php bin/wantedpages.php | grep -v "some:namespaces" | grep -v "wiki:nonexisting" | grep -v "wiki:pagename" > $wpages
grep -R -f $wpages data/pages/* | grep -v "\.svn"
rm $wpages

Explanation:

  • I have a grep -v “\.svn” because I have my wiki under subversion!
  • Also this lists both the broken link and the page at which it occurs

QR Code
QR Code tech:others:dokuwiki_cli (generated for current page)