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>
  • 写回答

1条回答 默认 最新

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

    You can use "&" et the end :

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

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘