【问题标题】:Running dynamic shell script from php从 php 运行动态 shell 脚本
【发布时间】:2011-11-02 04:01:30
【问题描述】:

我一直在编写一个与 festvox 一起使用的简单文本到语音 php 脚本,我一直在尝试使用它,但似乎我无法获得的部分是运行文本到波形转换器、shell 脚本。这是我到目前为止创建的代码,

<form action="index.php" method="get">
Say: <input type="text" name="say" />
<input type="submit" />
</form>
<?php
$myFile = "test.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $_GET["say"];
fwrite($fh, $stringData);
fclose($fh);
shell_exec('text2wave /var/www/text.txt -otype aiff -o /var/www/out.aiff');
?>

所以我想知道我可能会犯什么错误,有什么帮助吗?

【问题讨论】:

  • 一个(不相关的)错误是没有利用file_put_contents()
  • 你检查错误日志了吗?还是重定向stderr?
  • 您可能需要提供 text2wave 的完整路径? /usr/bin/text2wave 等

标签: php shell command text-to-speech


【解决方案1】:

您收到什么错误消息?但是,如果我想从该代码中猜测,并且该 shell_exec 命令可在 CLI 中运行,那么请尝试使用 text2wave 程序的完整路径。

【讨论】:

  • 如果我从 php 脚本运行它,我在哪里可以找到我在 ubuntu 上的控制台错误日志?
  • 如果您使用 Apache 作为 Web 服务器,stderr 很可能会输出到您的 Apache 错误日志,该日志位于 /usr/local/apache/logs/error_log 等位置。
  • 我认为我得到了权限错误,所以我可以在文件中输入密码
  • 我把这个,sudo -u trevorr -S /usr/bin/text2wave /var/www/text.txt -otype aiff -o /var/www/out.aiff
  • [sudo] www-data 的密码:对不起,再试一次。 [sudo] www-data 的密码:对不起,再试一次。 [sudo] www-data 的密码:对不起,再试一次。 sudo: 3 次错误密码尝试
猜你喜欢
  • 2012-03-28
  • 1970-01-01
  • 1970-01-01
  • 2012-01-15
  • 2019-04-08
  • 1970-01-01
  • 1970-01-01
  • 2013-06-13
相关资源
最近更新 更多