有点特别的问题。我正在用php开发一个自动脚本,以便在客户需要设置演示站点时帮助创建演示web应用程序。
我使用的是运行plesk的专用服务器。
我的目的是创建一个新的子域,创建一个新的数据库,从其他地方复制数据库,从另一个文件夹复制站点文件,最后用他们的登录凭据给客户发送电子邮件,等等。
我正在使用plesk api rpc创建子域、数据库和数据库用户,它们都工作得很好。我让数据库从其他地方复制模式,我让电子邮件部分工作。唯一让我难以捉摸的是将文件从一个文件夹复制到另一个文件夹。
源文件夹与目标文件夹位于同一“httpdocs”文件夹中。我最初遇到的问题是open_basedir问题,我已经纠正了这个问题,但是现在我遇到了拒绝许可的问题。
我知道我不能用窗户。
我试过通过exec()使用xcopy,它返回

string(13) "Access denied"

我也试过cacls和icacls,这两个都给了我一个类似的错误
string(57) "Successfully processed 0 files; Failed processing 1 files"

除了给整个httpdocs文件夹写权限之外,我对如何更好地实现这一点有点不知所措。任何建议/帮助都将不胜感激。

最佳答案

这个脚本对我很有用:

<?php

echo(system('xcopy /Y /Z "C:\Inetpub\vhosts\example.tld\httpdocs\index.html" "C:\Inetpub\vhosts\example.tld\httpdocs\index2.html"'));

您可以使用xcopy:
C:\Inetpub\vhosts\example.tld\httpdocs>xcopy index.html index5.html
Does index5.html specify a file name
or directory name on the target
(F = file, D = directory)? F
C:index.html
1 File(s) copied

但并非所有情况下:
C:\Inetpub\vhosts\example.tld\httpdocs>xcopy /O index.html index4.html
Does index4.html specify a file name
or directory name on the target
(F = file, D = directory)? F
Access denied
0 File(s) copied

也可以使用icacls:
C:\Inetpub\vhosts\example.tld\httpdocs>icacls index3.html /grant ftp3:(F)
processed file: index3.html
Successfully processed 1 files; Failed processing 0 files

你甚至可以禁用吸入:
C:\Inetpub\vhosts\example.tld\httpdocs>icacls index4.html /inheritance:r
processed file: index4.html
Successfully processed 1 files; Failed processing 0 files

09-30 16:19
查看更多