I am on EC2 and logged in with ec2-user
.I am using following script to execute a Python script from Apache. IT works from command line but not from web and does not print any output at all. The code is below:
我在EC2上并使用ec2-user登录。我正在使用以下脚本从Apache执行Python脚本。 IT可以从命令行运行,但不能从Web运行,也不会打印任何输出。代码如下:
<?php
$command = escapeshellcmd('python3 /home/ec2-user/f1/f2/file.py');
$output = shell_exec($command);
echo $output;
?>
Same script works fine from command line
相同的脚本在命令行中运行良好
1 个解决方案
#1
0
Ssh the server and execute this command:
Ssh服务器并执行以下命令:
which python3
It will show you some path so update your command like this:
它会显示一些路径,所以更新你的命令,如下所示:
path/to/python3 /home/ec2-user/f1/f2/file.py
#1
0
Ssh the server and execute this command:
Ssh服务器并执行以下命令:
which python3
It will show you some path so update your command like this:
它会显示一些路径,所以更新你的命令,如下所示:
path/to/python3 /home/ec2-user/f1/f2/file.py