简体   繁体   English

exec()不能按预期工作

[英]exec() doesn't work as expected

I'm running a script using exec from a php file. 我正在从php文件中使用exec运行脚本。 In the scipt there is a creation of a folder and a file inside it. 在Scipt中,将创建一个文件夹和一个文件。 The folder is created well but it remains empty after the script is finished. 文件夹创建良好,但脚本完成后仍为空。 I have looked at the return value from the exec call and everything seems about right, so I'm not sure if it's permissions problem or not(wouldn't I get permission denied if that was the case?). 我已经查看了exec调用的返回值,并且一切似乎都正确,所以我不确定是否是permissions问题(如果是这种情况,我是否会permission denied ?)。 Anyway if it is permission problem' please tell me how to give the right permissions to the www-data user. 无论如何,如果这是权限问题”,请告诉我如何为www-data用户授予正确的权限。

[Edit]: I have played with the script a little and I saw that it can create files in that folder. [编辑]:我玩了一点脚本,发现它可以在该文件夹中创建文件。 The problem is, that the script create the file I need like this: sqlite3 myFile.db < mySql.sql , so the problem is probably there. 问题是,脚本会像这样创建我需要的文件: sqlite3 myFile.db < mySql.sql ,所以问题可能就在那里。 Any ideas? 有任何想法吗?

After creating the folder please give permission to it by using below code 创建文件夹后,请使用以下代码授予权限

chmod("complete-folder-path", 0777); chmod(“ complete-folder-path”,0777);

After that create file in it. 之后,在其中创建文件。 It will work. 它会工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM