1

I try to run my php script from python.

Here is my php code:

<?php
require '../functions/server_info.php';
require ('../functions/functions.php');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
$input_data_trunk = array();
$input_data_trunk['ami_category']="TRK-IPU";
$IP = "192.168.1.200"; 
conf_sip_action($input_data_trunk, 'new', 'trunk');
echo "done";
?>

Then I write python code i execute this script, but I have error like this:`

PHP Warning: require(../functions/server_info.php): failed to open stream: No such file or directory in /var/www/html/IPU-GUI/website2/LTU_trunk.php on line 2
PHP Fatal error: require(): Failed opening required '../functions/server_info.php' (include_path='.:/usr/share/php') in /var/www/html/IPU-GUI/website2/LTU_trunk.php on line 2

Here is my python code (just execute script):

import subprocess
subprocess.call( ["/usr/bin/php", "/var/www/html/IPU-GUI/website2/LTU_trunk.php"] )

I am looking for help.

Thanks in advance.

`

asked Aug 9, 2017 at 9:37
1

1 Answer 1

3

require .. is relative to the current working directory/the PATH setting, not the current PHP file. When executing from Python, the working directory will be either undefined or simply different from what you might expect. Use an absolute import path/relative to the file:

require dirname(__DIR__) . '/functions/server_info.php';
answered Aug 9, 2017 at 9:42
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.