Reputation:
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.
`
Upvotes: 1
Views: 2277
Reputation: 522513
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';
Upvotes: 3