代码之家  ›  专栏  ›  技术社区  ›  hardy charles

在php中设置用于发送电子邮件的计划任务时出错

  •  0
  • hardy charles  · 技术社区  · 7 年前

    $input = 'schtasks /create /tn testSendMail /tr "php\"D:\wamp64\www\testScheduler\SchedulerURL.php"" /sc once /st 11:00';
    $input = escapeshellcmd($input);
    echo $input;
    $execution = exec($input." 2>&1",$output);
    var_dump($execution);
    var_dump($output);
    

    当我执行这个时,我得到:

    array(2) { [0]=> string(93) "Erreur�: Le code XML de la t�che contient une valeur incorrectement format�e ou hors limites." [1]=> string(12) "(39,4):Task:" }
    

    英语:

    task XML code contains incorrect values format or is out of bounds
    

    但当我在终端上执行这个命令行时,它会创建一个调度任务。

    0 回复  |  直到 6 年前
        1
  •  0
  •   elkolotfi    7 年前

    我想问题出在你的指挥上:

    "php\"D:\wamp64\www\testScheduler\SchedulerURL.php""
    

    转义字符时出现一些问题。

    因此,我会选择:

    "php \"D:\\wamp64\\www\\testScheduler\\SchedulerURL.php\""
    

    另一个建议是,更喜欢使用魔术常量 尽管使用手写的绝对路径。

    希望这有帮助。

        2
  •  0
  •   hardy charles    7 年前

    好吧,如果有人有同样的问题,我知道了。 当我找到解决方案时,我会对此进行评论。