【发布时间】:2023-04-03 01:20:02
【问题描述】:
在我的代码的某些部分,我比较了 2 个文件并使用 exec() 函数将差异输出到另一个文件。
在exec 函数中我使用comm -13 <(sort file_a) <(sort file_b) > output
当我运行我的 php 代码时,它会创建输出文件,但文件本身是空的。当我直接将命令复制并粘贴到终端时,它也会填充具有差异的文件,但不会在 php 上填充我的输出文件。
部分代码;
exec('bash -c \'comm -13 <(sort "' . $path_d_raw.$least_recent_raw_file . '") <(sort "' . $path_d_raw.$most_recent_raw_file . '") > test.txt 2>&1\'', $output, $return);
$path_d_raw.$least_recent_raw_file and $path_d_raw.$most_recent_raw_file 路径正确,/file 测试了一百次。
我也尝试使用shell_exec,但无法以任何方式完成。
【问题讨论】: