[英]Run bash script to create file in PHP
In addition to my previous question , another problem appeared and I decided to make a new question for it: 除了我之前的问题 ,还出现了另一个问题,我决定为它提出一个新问题:
I am currently calling a php script that than runs a bash script. 我目前正在调用一个PHP脚本,而不是运行bash脚本。 The php script looks like:
php脚本看起来像:
chdir('/home/');
$output = shell_exec('./do.sh');
echo "<pre>$output</pre>";
The do.sh contains: do.sh包含:
#! /bin/bash
echo 12;
dd if=/dev/urandom of=test.test bs=1048576 count=2
The problem is following: 问题如下:
When I call ./do.sh
from the terminal everything works fine: test.test is created and the ouput is 12
当我从终端调用
./do.sh
,一切正常:test.test创建,输出为12
However, when I call it from my php file, the output is 12
aswell, but no file is being created. 但是,当我从我的php文件中调用它时,输出也是
12
,但是没有创建文件。 Since I know almost nothing about bash scripting, I have no idea why this is happening... 由于我对bash脚本几乎一无所知,我不知道为什么会发生这种情况......
Check if PHP safe_mode is enabled. 检查是否启用了PHP safe_mode。 You have to turn it off in your /etc/php.ini file, and obviously check filesystem permissions.
您必须在/etc/php.ini文件中将其关闭,并显然检查文件系统权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.