Jump to content


Photo

${US_ROOTF} wrong value when using php-cli.ini from CLI


  • Please log in to reply
4 replies to this topic

#1 carlopug

carlopug

    Newbie

  • Member
  • Pip
  • 3 posts
  • Main OS: Windows 7

Posted 23 January 2015 - 12:08 PM

Hi to everybody,

this is my first post here.

 

I've a problem sending email from php54 CLI.

The .ini file used is php-cli.ini from core\php54 folder.

 

But the ${US_ROOTF} variable in the .ini contain the user home directory in windows (ex. "C:\Users\username\AppData\Roaming\").

 

How about this strange behaviour?

 

TIA,

Carlo 



#2 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 23 January 2015 - 01:51 PM

Please supply example code, do not include a real email address.

Explain how you run this code.

 

All the best

Ric



#3 carlopug

carlopug

    Newbie

  • Member
  • Pip
  • 3 posts
  • Main OS: Windows 7

Posted 24 January 2015 - 05:39 AM

Sure!

 

This is the code of test.php file:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

mail("to@email.com", "Subject", "Line 1\nLine 2\nLine 3");
die();

This is the command line to run the code:

F:\UniServerZ\core\php54\php -f F:\Home\Dropbox\test.php

This is the error message:

Impossibile trovare il percorso specificato.

that sounds like "unable to find the specified path" or something silimar (I use italian OS).

 

I think that the ${US_ROOTF} variable contains a wrong path value... 

 

This is the command line to see the default configuration file loaded:

f:\uniserverz\core\php54\php -r "print (php_ini_loaded_file());"

the output result is:

F:\uniserverz\core\php54\php-cli.ini

php-cli.ini default file contains:

[PHP]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PHP PHP 5.4.32 CLI  php-cli.ini    ;
; Uniform Server PHP CLI php-cli.ini ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

extension=php_curl.dll
extension=php_mysql.dll
extension=php_openssl.dll
extension=php_gd2.dll
extension=php_pdo_mysql.dll
extension=php_mbstring.dll

extension_dir = "./extensions"
;error_reporting = E_ALL | E_STRICT
error_reporting = E_ALL 
date.timezone = "Europe/Rome"

sendmail_path = "${US_ROOTF}/core/msmtp/msmtp.exe --file=${US_ROOTF}/core/msmtp/msmtprc.ini  -t"

[COM_DOT_NET]
extension=php_com_dotnet.dll

If I try to change sendmail_path configuration with

sendmail_path = "F:/UniServerZ/core/msmtp/msmtp.exe --file=F:/UniServerZ/core/msmtp/msmtprc.ini  -t"
the following error comes out:
F:/UniServerZ/core/msmtp/msmtp.exe: cannot log to C:\Users\utente\AppData\Roaming\core\msmtp\msmtp.log: cannot open: No such file or directory

and the email was correctly send. In the last error message I can see the USER HOME path so I think that  ${US_ROOTF} contains it.

 

This solution is not the best...

What can I do?

 

TIA,

C.

 


#4 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 24 January 2015 - 02:07 PM

I assume you are running the following command line:

 

F:\UniServerZ\core\php54\php -f F:\Home\Dropbox\test.php

 

from a standard command prompt (cmd). What is missing are two environment variables HOME (required by msmtp.exe) and US_ROOTF (required by php-cli.ini)

UniController automatically creates these environment variables. For example run UniController and click "Server Console" button this opens a console window (command prompt). Now enter the command line:

 php -f F:\Home\Dropbox\test.php

 your script will run correctly. Generally if you are using the command line to run PHP scripts use this command prompt.

All the best
Ric



#5 carlopug

carlopug

    Newbie

  • Member
  • Pip
  • 3 posts
  • Main OS: Windows 7

Posted 24 January 2015 - 02:50 PM

You are right!!!

Thank you very much!!!

 

I never used the server console before... 

 

Setting HOME and US_ROOTF variables from the batch before calling php is the right way to solve the problem.

 

Is there a method to force the server console environment to call custom batch?

 

TIA,

C.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users