Command Line Instructions

Advanced Questions & Problems

Moderators: Dragonrider, J_S, Hernol, vancoovur, H2B2, Heritage

Do you use commandline to process queue?

Yes, it worked easy!
4
8%
It worked after lots of hours
13
25%
I tried and never worked
22
42%
I would like to try it in the future
10
19%
No, I don't need it
4
8%
 
Total votes : 53

Command Line Instructions

Postby alkibsi » 8:46pm, Sat 05 Jun, 2004

Just by reading many of the problems people face, and from my personal experience, and due to the fact that this application is outstanding. And processing the queue, and bounced emails is the distinguishing factor behind the success of this wonderful software. I am requesting to utilize this thread to illustrate processing the queue and bounced mail via commandline or cron job. Step by step for users who are for the first time use cron jobs, or shell access.
alkibsi
phplister
 
Posts: 12
Joined: 4:44pm, Sun 30 May, 2004

Postby alkibsi » 9:15pm, Sat 05 Jun, 2004

Code: Select all
Running PHPlist from the commandline

Commandline processing requires PHP 4.3.0 or higher

A few pages in the PHPlist system can now, as of version 2.7.0 be run with
a simple command from the commandline.

the script to use is called "phplist" in the "bin" directory. You will have to edit
this script to fit your system

The normal PHPlist access restrictions are bypassed, but the Unix users who are
allowed to run the script should be mentioned in the "commandline_users" config
variable. The identity of a user is determined by the USER environment variable, which
may not always match your system.

The "p" parameter is the page that needs to be run.
Currently you can use "send", "processqueue" and "processbounces"

phplist -psend

This will require some more arguments:

-l list
-s subject
[-f from]

and you need to "pipe" the message into the script.

The -l parameter can have two types of values, the name of the list or the number of the list.
You can added multiple lists or multiple -l parameters
The subject can have spaces
The from is optional. It will default to the system administrator as set up in your config.

So the full "send" command line would be:

phplist -psend -s This is the subject -l test 1 2 3 -f me@server.com < messagefile
alkibsi
phplister
 
Posts: 12
Joined: 4:44pm, Sun 30 May, 2004

Re: Command Line Instructions

Postby robalan » 3:56pm, Wed 09 Jun, 2004

alkibsi wrote:I am requesting to utilize this thread to illustrate processing the queue and bounced mail via commandline or cron job. Step by step for users who are for the first time use cron jobs, or shell access.


Dude... anyone can see this in the README. Where's the step by step part? I know I would appreciate some help with the cron.

Thanks
Rob Alan
robalan
PL Nut
 
Posts: 24
Joined: 9:25pm, Sat 24 Apr, 2004

Just a start

Postby alkibsi » 6:57pm, Wed 09 Jun, 2004

I put the help file, to be a start.
I need more help for the help file..!! :cry:
alkibsi
phplister
 
Posts: 12
Joined: 4:44pm, Sun 30 May, 2004

User??

Postby coolman » 11:45am, Tue 06 Jul, 2004

Hi,

please sorry for my bad english :shock:
I´m using PHPlist on my Homepage www.dynaglobe.de and i´d tried to
using the command line feature from phplist.

1st i´d fixed up the phplist script and i´d putted the file on my root directory in the bin directory

then i logged in as root.
what command_line_user must be setup in the config.php, when i logged in as root??

and what must be do, to send queed messages as root in the shell??

thank you, for your help!!
coolman
phplist newbie
 
Posts: 2
Joined: 11:26am, Tue 06 Jul, 2004

cron job guide

Postby larson » 6:26pm, Tue 06 Jul, 2004

I would also really like a clear step by step guide to the cron jobs/commandline. I've read and re-read what info is included w/ Phplist but it seems aimed at someone who has set that type of stuff up before. A clearer guide would be greatly appreciated and then could be included in the readme that comes with Phplist.
-Larson
larson
PL Nut
 
Posts: 31
Joined: 10:22pm, Mon 26 Apr, 2004

How To: commandline processqueue

Postby sal » 1:31am, Sun 11 Jul, 2004

My First post and just like to say RESPECT to MICHIEL for this program :D

Am trying to do the commandline processqueue but can't figure it out.

here is what i've done so far:

placed the phplist file with the right paths in /usr/bin

#!/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

# identify the config file for your installation
CONFIG=/home/USER/public_html/list/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
/usr/bin/php /home/USER/public_html/list/admin/index.php $*


chown and chgrp are 'root' for phplist in /usr/bin
-rwxr-xr-x 1 root root 642 Jul 11 01:18 phplist*


placed 'root' in config/config.php '$commandline_users variable' :

$commandline_users = array("admin", "root");

from what i can tell that should be it. now i am stuck :!:

tried # phplist -pprocessqueue

i got the html of the admin login page which makes me think that my permissions are wrong.

would love a proper how to or any suggestions.

it's annoying to have to keep refreshing the browser.

:D
sal
phplist newbie
 
Posts: 3
Joined: 1:02am, Sun 11 Jul, 2004

putting "phplist" file bin

Postby larson » 5:04pm, Mon 12 Jul, 2004

what do I need to do in order to get the "phplist" script into the usr/bin/ directory? i can't seem to ftp it. the only way I've been able to get into that directory is via shell access and I'm not sure how to upload files that way. i'm sure this is a very beginner question... but any help would be greatly appreciated! thanks!!
-larson
larson
PL Nut
 
Posts: 31
Joined: 10:22pm, Mon 26 Apr, 2004

Postby sterlinged » 6:03pm, Mon 12 Jul, 2004

The very first thing you need to do when trying to run PHPlist from the command line, is to make sure you have the command line version of PHP. It is very possible that you or your host does not. To find out, from a command line prompt, type:

Code: Select all
php -v


(or similar syntax for your distribution. I happen to be on a Mandrake box).

What is returned is similar to below:

Code: Select all
PHP 4.3.1 (cli) (built: Jul 28 2003 11:46:14)


Most importantly, that (cli) bit, then you have the command line version of PHP. Now we can get somewhere. If you don't see the (cli) then chances are, you don't have it. If it's your box, a simple rebuild of PHP as cli will work for you. Being on Mandrake, I simply fired up the package manager and selected the cli version of PHP and voila. If you're on a hosted environment, your chances of getting a new version of PHP done are slim. You can certainly ask your host if it would be possilbe.

Now if you find that you _do_ have the cli version of PHP, here's what I did to get it working. (keep in mind, I'm leaving out all of the head pounding and hair pulling that abounded. :D)

1. FTP'ed phplist script to my shell account.
2. Logged in as root to my machine (using the su command).
3. cd'ed into my /sbin/ (where I store scripts, your's may be /usr/bin or something else)
Code: Select all
cd /sbin

4. mv'ed the phplist script from where I FTP'ed it in to the current directory:
Code: Select all
mv /home/admin/phplist phplist

5. chown and chgrp script for root (just in case)
Code: Select all
chown root phplist
chgrp root phplist

6. chmod script to be an executable
Code: Select all
chmod 775 phplist

7. Now cron needs to be set up. For me, cron is accessed by typing:
Code: Select all
crontab -e

This opens up the crontab in vi for root. Once I have that open I add the following lines to it:
Code: Select all
*/15 17-23 * * 2,3,4,5,6 /sbin/phplist -pprocessqueue
*/15 0 * * 2,3,4,5,6 /sbin/phplist -pprocessqueue
*/15 1-6 * * 2,4,6 /sbin/phplist -pprocessqueue
10 1 * * 3,5,7 /sbin/phplist -pprocessbounces

This is how I've set up my scripts to fire. We have a large list of users with many (300+) lists so it's important the script fires often. If you don't know the syntax for cron, I suggest you google for it. Basically the first line says I want the script to run every 15 minutes starting at 5 p.m. (17) and running through 11:00 p.m. (23). This should happen Mon. (2) through Fri. (6). Second line does the same thing over, except runs it at midnight as well (0). (as an aside, this means it will run at 12:00, 12:15, 12:30 and 12:45.) The third line sets the script to run from 1 a.m. to 6 a.m. (every 15 minutes) only on Mon., Wed., and Fri. The last line is for processing bounces. I run it starting at 1 a.m. Tue., Thu., and Sat.
One note about cron and your system. It's entirely dependant on your setup and distro what the actual syntax of the commands may be. Find out what you're running for cron, and then enter the commands above with any changes that may need to be made.
8. Once that's set up, you need to make sure your phplist script is set up with the correct options. Making sure you are still in the same directory as phplist cli script, do this:
Code: Select all
vi phplist

(or open with your editor of choice. No flame wars! :D)
Once opened, you need to edit certain lines:
Code: Select all
CONFIG=/home/USER/public_html/list/config/config.php
-needs to be edited to where your config file is located.

/usr/bin/php /home/USER/public_html/list/admin/index.php $*
-again, you need to edit where your admin login is and possible where the php binary is, if it's not in the normal spot there (/usr/bin/php)

9. Now that that is done, you have one last place to edit. In your config file, make sure you enter the users (this is the user on the system, not your PHPlist user. In my case, it would be root.) that will be using the script.
10. A good way to test it is to type
Code: Select all
phplist -pprocessqueue

on the commandline. If it's set up wrong, quite surely you will receive an error like this:
Code: Select all
PHPlist version 2.8.8 (c) 2000-2004 Tincan Ltd, http://www.phplist.com

Error: Sorry, You (admin) do not have sufficient permissions to run this script

Now, the reason I got this error is that my admin account isn't set to run scripts in the config file, even though I'm su'ed as root. To get around this problem, I entered a setting into my crontab that fired off the script every 5 mintues. Then I sat back and waited. When my cronlog showed up in my email, I found something interesting:
Code: Select all
PHPlist version 2.8.8 (c) 2000-2004 Tincan Ltd, http://www.phplist.com

Error: Sorry, You () do not have sufficient permissions to run this script

Apparently, the script was trying to be run as () a blank user. Now I am not a sysadmin guru in the least, and maybe someone can help me out, but to fix it, I changed my config file to allow a blank user to run the script. Tried again, and this time it worked.

As I said earlier, most of these settings are dependant on your system setup and what distro you're using. The most important thing is that you need to have a command line (cli) version of PHP. Once you know that you have that, make sure you have an understanding of cron and it's syntax for your machine, and be comfortable moving around on the command line environment and in your editor of choice.

Most likely there are some errors in my post as I'm doing this from memory. If you have problems or such, please let me know and maybe we can work them out. Also, if anyone sees some super-glaring errors in here, let me know. :-D

Thanks,
Erik
sterlinged
PL Nut
 
Posts: 19
Joined: 3:52pm, Wed 20 Aug, 2003
Location: Eau Claire, WI

cool!

Postby larson » 7:31pm, Mon 12 Jul, 2004

thanks for that tutorial!! i think i've got things going a bit better now but now when I type "phplist -pprocessqueue" a ton of html comes up. i can't tell which page it is but i don't think it is what I want to be seeing. any ideas? thanks so much again for the set up guide!!
-larson
larson
PL Nut
 
Posts: 31
Joined: 10:22pm, Mon 26 Apr, 2004

PHP Version

Postby coolman » 12:32am, Tue 13 Jul, 2004

Hi,

my php version is

PHP 4.3.3 (cgi) (built: Nov 10 2003 13:05:54)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

is this the correct version vor command line instructions??
When not, where can i get the correct version an how can i update the old php version??

thanks
coolman
phplist newbie
 
Posts: 2
Joined: 11:26am, Tue 06 Jul, 2004

Postby sterlinged » 4:44pm, Tue 13 Jul, 2004

coolman,
No I don't think it is. See after your PHP where it has (cgi)? That means it's the cgi version of PHP, not command line (cli).

How you go about getting it is dependant on what your complete system set-up is. If you're on a hosted box, you'll need to contact your host about it. If it's your own box, you can either try getting the cli version from the package manager or rpm manager on your system, or you can roll your own install of php with (cli). Do a google for how to build it on your specific system.

Personally, to go from PHP (cgi) to PHP (cli) all I had to do was an install from the Mandrake package manager.

Erik
sterlinged
PL Nut
 
Posts: 19
Joined: 3:52pm, Wed 20 Aug, 2003
Location: Eau Claire, WI

Postby sterlinged » 4:46pm, Tue 13 Jul, 2004

larson,
What's your PHP version output like coolman posted above?

From the command line do:
Code: Select all
php -v


Erik
sterlinged
PL Nut
 
Posts: 19
Joined: 3:52pm, Wed 20 Aug, 2003
Location: Eau Claire, WI

Postby larson » 6:52pm, Tue 13 Jul, 2004

When I do php -v this is what I get

PHP 4.3.3 (cli) (built: Jun 8 2004 19:27:04)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies


I saw the thread about the commandline not working when it was a cgi version of PHP but mine does say (cli)? not sure whats up. Thank you for any help!!
-Larson
larson
PL Nut
 
Posts: 31
Joined: 10:22pm, Mon 26 Apr, 2004

Postby sterlinged » 7:04pm, Tue 13 Jul, 2004

larson,
That looks like it to me.

Could you post the first few lines of output after you type phplist -pprocessqueue? Also, does anything happen after the html outputs?

Thanks,
Erik
sterlinged
PL Nut
 
Posts: 19
Joined: 3:52pm, Wed 20 Aug, 2003
Location: Eau Claire, WI

Next

Return to Advanced Questions & Problems

Who is online

Users browsing this forum: No registered users and 0 guests