无法将 OCaml 字节码的输出重定向到 Windows 服务器中的文件

Cannot redirect the output of an OCaml bytecode to a file in Windows server

我已经编写了一个基本的 OCaml 文件 test.ml,并编译了我的 Windows 服务器。它在命令提示符下工作:

但是,如果我运行它在php,只有最后一行(即testbat.bat)成功写入result.txt,而 test.exe 总是失败:

exec('C:\PRODSERVER\OCamlTest\test.exe >> C:/inetpub/testaddbbacom/test/result.txt');
exec('C:/PRODSERVER/OCamlTest/test.exe >> C:/inetpub/testaddbbacom/test/result.txt');
exec('C:\PRODSERVER\OCamlTest\test.exe >> C:/inetpub/testaddbbacom/test/result.txt');
exec("C:\PRODSERVER\OCamlTest\test.exe >> C:/inetpub/testaddbbacom/test/result.txt");
exec('C:/PRODSERVER/OCamlTest/testbat.bat >> C:/inetpub/testaddbbacom/test/result.txt');

有人知道怎么解决吗?

或许您可以尝试此处描述的解决方案:Batch-file get return Value from exe ?

可能是 exe 使用的输出类型有问题。由于您的 .txt 文件的第一行,我认为程序已成功写入...具有空值。

我找到了解决方案:在编译时添加 -custom 作为 ocamlc 的选项...