【问题标题】:Calling Octave from PHP using either system, exec or passthru使用系统、exec 或 passthru 从 PHP 调用 Octave
【发布时间】:2014-01-28 16:27:06
【问题描述】:

我正在尝试在 Eclipse 环境中从 PHP 执行 Octave 脚本。 PHP 的设置,Apache 的工作呢。该问题与以下调用有关:

$cmd = "octave3.8 -qf /.../path_to_file/myscript.m file.txt";
$ex = passthru($cmd, $output);
var_dump($ex);
var_dump($output); 

在脚本 myscript.m 中有:

e = 5                % too see if it will be printed onto the web page
arg = argv();        
data = load(arg{1}); 

结果是: NULL int(1)

几个主题演讲:

  • 来自终端的相同命令工作正常(octave3.8 -qf /../path_to_file/myscript.m file.txt)
  • 我已经尝试让 PHP 进程由 sudoer 运行

在 Ubuntu 12.04、Octave 3.8.0、Eclipse 标准/SDK 2.0.1.、PHP 开发工具 3.2.0.

【问题讨论】:

  • 你做到了吗?
  • 你有什么解决办法吗,请分享..

标签: php octave


【解决方案1】:

你的命令行应该是:

octave --no-gui --quiet /path/to/script.m

脚本的内容应该是:

e = 5;
disp(e);

【讨论】:

  • 它也不起作用。命令 -q 用于安静,并且没有 gui 是 octave 3.8.0 上的默认值
  • @eykiriku,我不这么认为。至少在 Linux 版本中,GUI 是默认设置。您需要-q 来使 Octave 欢迎消息静音。另外,请注意argv(),它包含所有您在命令行中传递的标志和额外参数。
【解决方案2】:

你真的想这样做吗?新的 Octave 版本不支持管道。当用户键入文件或系统相关的八度函数等命令时,您可能会遇到许多安全问题。当您使用 octave through pipe 时,新的图形工具包 fltk 将挂起。您仍然有兴趣在 google 上搜索在线 octave。 嗯。有 Nclab,它是基于云的。

【讨论】:

  • 管道是什么意思?这个 php 脚本不需要用户的任何输入。我的 PHP 脚本的流程是:PHP 访问数据库,检索文件“file.txt”,将其传递给 octave,它将完成所有处理并给出结果返回 PHP 脚本以保存到另一个文件或打印到网页。使用 Nclab 而不是在网络服务器上独立安装 octave 有什么好处?
猜你喜欢
  • 1970-01-01
  • 2010-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多