Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Php exec()执行外部.exe_Php_Permissions_Command_Exec_Exe - Fatal编程技术网

使用Php exec()执行外部.exe

使用Php exec()执行外部.exe,php,permissions,command,exec,exe,Php,Permissions,Command,Exec,Exe,我无法正确使用exec()函数。我有一个外部可执行文件,我可以从设备中的用户运行它,它运行正常,但使用PHPexec()函数,它运行不正常 细节 drwxr-xr-x. 2 root root 4096 Kas 18 07:41 . drwxr-xr-x. 27 root root 4096 Eyl 21 04:15 .. -rwxr-xr-x 1 root root 11169253 Kas 18 06:43 example.exe 作为用户,这个命令没问题,它可以创建

我无法正确使用
exec()
函数。我有一个外部可执行文件,我可以从设备中的用户运行它,它运行正常,但使用PHP
exec()
函数,它运行不正常

细节

drwxr-xr-x.  2 root root     4096 Kas 18 07:41 .
drwxr-xr-x. 27 root root     4096 Eyl 21 04:15 ..
-rwxr-xr-x   1 root root 11169253 Kas 18 06:43 example.exe
作为用户,这个命令没问题,它可以创建文件

/srv/example.exe 'examplefile.tmp' '/srv/exampleout.tmp'
exec("/srv/example.exe 'examplefile.tmp' '/srv/exampleout.tmp'", $op, $ret);
但是,当我对php exec()函数使用相同的命令时,它似乎工作成功,但无法创建out文件

/srv/example.exe 'examplefile.tmp' '/srv/exampleout.tmp'
exec("/srv/example.exe 'examplefile.tmp' '/srv/exampleout.tmp'", $op, $ret);
这样,

$op = empty array
$ret = int 1

你知道吗?

这个有趣的文件扩展名
.exe
在类unix系统中有什么作用?很可能你正面临文件权限问题。请记住,在http服务器中运行php脚本时,由
exec()
启动的进程将在http进程的帐户和权限配置文件下运行。该帐户很可能没有
/srv
的写入权限。谢谢,我如何才能授予http进程对srv/的写入权限?我只尝试了“chmod 755 srv/”命令。您不应该在该位置存储运行时文件。为此使用特定文件夹,并通过http服务器进程的组成员身份授予写访问权限。