in reply to Verify WordPress user password via Perl

Thanks, I went through using the WordPress hashing functions.
So from a Perl CGI I execute this kind of php code (I will have to pass user and password in the call) that I saved into an .htaccess-protected directory so that it can only be called from the Perl script:
<?php $username = 'myuser'; $plain_password = 'mypassword'; require_once('/path/to/wp-blog-header.php'); require_once('/path/to/class-phpass.php'); $userdata = get_user_by('login', $username); $result = wp_check_password($plain_password, $userdata->user_pass, $us +erdata->ID); if ( $result ) { echo "1"; } else { echo "0"; } ?>

Then the Perl CGI calls it as

$ok = `php /path/to/check_password.php`;

The problem is that when I call the php from the browser it gives 1 or 0 back, but apparently from Perl it gives back an empty space.
Thanks you for any hint.

Replies are listed 'Best First'.
Re^2: Verify WordPress user password via Perl
by jethro (Monsignor) on Dec 20, 2011 at 10:07 UTC

    First you should call the php script from the command line and check if you see the result output.

    Then call the perl script from the command line (or an abbreviated test script). If it works, the malfunction comes from calling it in the browsers environment

    Then try to call it like this:

    @ok= `php /path/to/check_password.php`;

    and check if you get back more than one line (although I don't see where an additional line could come from)