duanci5913
2017-02-09 11:34
浏览 47
已采纳

在执行时从PhP运行连续的Python脚本和重新加载页面

<?php 
  $time=$_GET[ 'time'];
  $date=$_GET[ 'date'];
  if($time !="" & $date !="" ){ 
    $hour=s ubstr($time,0,2);
    $minute=s ubstr($time,3,2);
    $day=substr($date,8,2);
    $month=substr($date,5,2);
    $year=substr($date,0,4);
    $execute=exec("python ..\alarm.py $year $month $day $hour $minute"); 
  }
?>


<form action="index.php" method="get">
  <input type='date' name='date'>
  <input type='time' name='time'>
  <input type='submit' value='setAlarm'>
</form>

So i am working on some Code that should do the following:

  1. Clicking a Submit-button on my index.php should execute a python-script stored on the Server and submitting the params of the form
  2. The python script, which is a script that is continuously excecuting an alarm (it sets an alarm an waits until then to execute it -> so it is supposed to run until the alarm is finished)
  3. After the python script was started from the php script, the index.php should reload.

Right now, it all works without the reloading of the index.php. The file is being executed and after manually reloading the page, the index.php Shows me all running alarm.py scripts, which is all i want.

So is there a way, to force the reloading of the page, after the executing from php started?

</div>

图片转代码服务由CSDN问答提供 功能建议

 &lt;?php 
 
 $ time = $ _ GET ['time']; 
 
 $ date = $ _ GET ['date']; 
 
 if($ time!=”  “&amp; $ date!=”“){
 
 $ hour = s ubstr($ time,0,2); 
 
 $ minute = s ubstr($ time,3,2); 
 \  n $ day = substr($ date,8,2); 
 
 $ month = substr($ date,5,2); 
 
 $ year = substr($ date,0,4); 
 
  
 $ execute = exec(“python .. \ alarm.py $ year $ month $ day $ hour $ minute”);  
 
} 
 
?&gt; 
 
 
 
 
 
&lt; form action =“index.php”method =“get”&gt; 
 
&lt; input type ='  date'name ='date'&gt; 
 
&lt; input type ='time'name ='time'&gt; 
 
&lt; input type ='submit'value ='setAlarm'&gt; 
 \  n&lt; / form&gt;   
 
  
 
  
 
 
 
 

所以我正在处理一些应该做的代码 以下内容:

  1. 单击index.php上的Submit-button应执行存储在Server上的python脚本并提交表单的参数
  2. python脚本,它是一个连续发出警报的脚本(它设置一个警报等到那时执行它 - >所以它应该一直运行直到警报结束)
  3. 从php脚本启动python脚本之后,index.php应该重新加载。

    现在,一切正常,无需重新加载 index.php。 文件正在执行,手动重新加载页面后,index.php显示所有正在运行的alarm.py脚本,这就是我想要的。

    所以有办法,强迫 重启页面,从php开始执行后?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题