#!/bin/bash
#
# script to run PHPlist from commandline. You may need to edit this to make it work
# with your shell environment. The following should work for Bash

# in commandline mode, access is restricted to users who are listed in the config file
# check README.commandline for more info

# $Id: phplist,v 1.6 2005/07/14 00:35:40 killes Exp $

# identify the config file for your installation
# we use the -c config flag from drupal, so we dont need this
#CONFIG=`pwd`/modules/massmailer/engines/phplist/phplist/lists/config/config.php
#export CONFIG

# alternatively you can use -c <path to config file> on the commandline

# run the PHPlist index file with all parameters passed to this script
# if you do not have php in your path, you will probably have to add the path to php here eg: /usr/bin/php
if (php-cli -r 'return  TRUE;') > /dev/null; then
  # you have php-cli in your path, how lucky for you
  php-cli modules/massmailer/engines/phplist/phplist/admin/index.php $*
elif (php -r 'return  TRUE;') > /dev/null; then
  # you have php in your path, how lucky for you
  php modules/massmailer/engines/phplist/phplist/admin/index.php $*
elif (/usr/bin/php-cli -r 'return  TRUE;') > /dev/null; then
  # try generally installed path
  /usr/bin/php-cli modules/massmailer/engines/phplist/phplist/admin/index.php $*
elif (/usr/bin/php -r 'return  TRUE;') > /dev/null; then
  # try generally installed path
  /usr/bin/php modules/massmailer/engines/phplist/phplist/admin/index.php $*
elif (/usr/local/bin/php-cli -r 'return  TRUE;') > /dev/null; then
  # others have it here
  /usr/local/bin/php-cli modules/massmailer/engines/phplist/phplist/admin/index.php $*
elif (/usr/local/bin/php -r 'return  TRUE;') > /dev/null; then
  # others have it here
  /usr/local/bin/php modules/massmailer/engines/phplist/phplist/admin/index.php $*
else
  # you are on your own now dude
  echo "You do not have the php command line executable in your system path";
  echo "and it cannot be located in /usr/bin or /usr/local/bin."
  echo "Please edit the modules/massmailer/engines/phplist/bin/phplist file to correct this.";
  # edit this next line if you got the message above
  # change /path/to/php to the path on your system where php is
  #/path/to/php modules/massmailer/engines/phplist/phplist/admin/index.php $*
fi
