[英]File is readable for php code run from php-cli directly and not readable for php code run through php-cli inside bash script
I am calling a php script from a bash file by root user. 我正在由root用户从bash文件中调用php脚本。 The php code gives an error of file not readable exception.
php代码给出了文件不可读取异常的错误。 If I run the same php sript from php-cli by root user, the file is readable.
如果我由root用户从php-cli运行相同的php sript,则该文件可读。
I have own the file using command 我使用命令拥有文件
chown root:www-data "file"
and make the file readable by 并使文件可读
chmod +r "file"
Here's the content of my bash script 这是我的bash脚本的内容
while true; do
echo "Waiting for file changes"
OUTPUT=`inotifywait -rq -e create --format='%w%f' '/var/www/storage/app/public/raw_image'`
chown root:www-data "$OUTPUT"
sleep 0.5
php /var/www/scripts/script.php "$OUTPUT"
echo "Files were changed"
done
The file permission for my bash script file is 0755
我的bash脚本文件的文件许可权是
0755
Not sure might be a shebang issue. 不确定可能是一个shebang问题。 Try below solution one by one most probably first one solve your problem
尝试以下一种最可能的解决方案来解决您的问题
#!/usr/bin/php /var/www/scripts/script.php "$OUTPUT"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.