phplist -pprocessqueue fails to login in commandline mode?

Solutions for other phpList version 2 users
Forum rules
Please do not ask questions here, this is for Solutions you have discovered or come across.

phplist -pprocessqueue fails to login in commandline mode?

Postby justsomeone » 11:17pm, Sun 03 Feb, 2008

Hi,

I've searched the boars for help with this commandline problem, but didn't find it.

I've uploaded and configured the phplist commandline script
I've edited the config.php to seth $commandline_users to an empty array.

But when I try phplist -pprocessqueue the html generated tells me I need to log in. Am I missing a step?

I'm running version 2.10.5

Many thanks,

Jack
justsomeone
phpList newbie
 
Posts: 2
Joined: 11:12pm, Sun 03 Feb, 2008

Postby justsomeone » 9:05am, Tue 05 Feb, 2008

I got it sorted. I'm posting the solution here in case it helps anyone else.

Being able to run php from the command line doesn't necessarily mean that you have command-line PHP installed.

On *nix systems, you can check if PHP is installed in commandline mode by using the "php -v" command. If you don't see "(cli)" in the response, then you're not running command-line PHP and the phplist script just won't work properly. It won't log in.

So, if you find that the phplist script returns only the HTML for your login page, the problem may be that you're not runnign commandline PHP. And without a lot of hacking at the code, you're not going to get it to work.

A quicker route to goal is to call the page through a web browser in order to run the "process queue" command. The good news is that this can still be automated.

The steps involved in this are documented elsewhere, but here is a quick recap from memory.

First, make sure that your config.php is set back up to present the process queue option to logged in administrators.

# If you set up your system to send the message automatically, you can set this value
# to 0, so "Process Queue" will disappear from the site
# this will also stop users from loading the page on the web frontend, so you will
# have to make sure that you run the queue from the commandline
# check README.commandline how to do this
define ("MANUALLY_PROCESS_QUEUE",1);


Next you need to determine the command you need to run in order to request the correct admin page from your browser. Your *nix installation probably has one or more of the following preinstalled, any of which can do the job: lynx, curl, wget

The url you want to request is:
'http://www.example.com/lists/admin/index.php?page=processqueue&login=LIST_USER&password=PASSWORD'

where you have substituted your correct values for domain.com, LIST_USER, PASSWORD and anything else that doesn't fit your installation.

You can try this out from the commandline by trying each of the possible commands:

lynx 'http://www.example.com/lists/admin/index.php?page=processqueue&login=LIST_USER&password=PASSWORD'

curl 'http://www.example.com/lists/admin/index.php?page=processqueue&login=LIST_USER&password=PASSWORD'

wget 'http://www.example.com/lists/admin/index.php?page=processqueue&login=LIST_USER&password=PASSWORD'



Try each to see which works. If any of them returns HTML, then that command is available on your system - you just need to read through the generated HTML to make sure that you're seeing the right page.

Once you've established your command, cron it using the crontab -e command. This will bring you into an editor. Add the a line to call whatever command works for you. You might also want to read the docs on that command to check for any extra options which might be of use to you.

A typical crontab entry would look like
*/15 * * * * lynx -dump 'http://www.example.com/lists/admin/index.php?page=processqueue&login=LIST_USER&password=PASSWORD' > /dev/null


Try setting up a test mailing and wait to see if the cronjob kicks it off. The above cron line would run every 15 minutes on the quarter hour.

This method has the disadvantage of listing your admin username and password in the crontab entry. A slightly more secure option would be to place the command containing the username and password into a file owned by root and readable only by root. You could then schedule a job in root's crontab to run that file. This would keep the login details away from anyone but root.

And that's it. That's how I resolved the problem.

Most of the information above was available on phplist documentation and forums, but it took a bit of digging to locate it all.

Here's hoping this guide will get a few more people up and running!
justsomeone
phpList newbie
 
Posts: 2
Joined: 11:12pm, Sun 03 Feb, 2008

Postby davidhw » 8:34am, Tue 19 Feb, 2008

Thanks for that - my host (Bluehost) does exactly what yours does. I can execute a php file from the cron jobs, but not in command line mode.
davidhw
phpList newbie
 
Posts: 3
Joined: 8:04pm, Tue 04 Dec, 2007

Re: phplist -pprocessqueue fails to login in commandline mode?

Postby mbira » 5:50am, Fri 13 Aug, 2010

This worked great for me on Justhost. Since I'm a newbie to this, I'd like to offer a few tips to help other newbies:

You can take the above code and just paste it in your address bar first to make sure everything works right:

Code: Select all
http://www.domain.com/lists/admin/index.php?page=processqueue&login=LIST_USER&password=PASSWORD


Important note: I removed the
Code: Select all
' '
from around the above code to make it work in the address bar. You should be able to put that in and hit enter and your precess queue will run. Once that is working, then you need to go into your cron and set the job. This worked for me:

Code: Select all
lynx -dump 'http://www.domain.com/lists/admin/index.php?page=processqueue&login=USERNAME&password=PASSWORD'


Thanks again!
mbira
phpLister
 
Posts: 6
Joined: 11:44pm, Tue 24 Mar, 2009


Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 0 guests