duanci5913 2017-02-09 03: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>
  • 写回答

1条回答 默认 最新

  • doulingzhuang3079 2017-02-09 04:03
    关注

    You can use "&" et the end :

    exec("python ..\alarm.py $year $month $day $hour $minute &");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部