【发布时间】:2014-04-21 13:47:58
【问题描述】:
我想知道我们是否可以从浏览器中的 html 页面创建文件到 linux 服务器文件夹?我有一个创建 txt 文件的 shell 脚本。但是当我使用 ajax 从浏览器触发此脚本时,它不会创建任何文件。我将所有权限授予父目录,但我仍然没有看到文件创建,也没有任何错误。
test.sh
echo "first sh"
java HelloWorld
echo "t1 test" > t1s
if [ ! -f t1s ]
then
echo "Shell File is not created .."
else
echo "Shell file is created.. "
fi
------
first.php
<?php
$output=shell_exec('sh test.sh');
echo "Hello Php \r\n";
echo $output;
echo "done \r\n";
?>
-----------
This is the output from command line:
Hello Php
hello first sh Shell file is created..
done
----------------
This is the output from broswer:
Hello Php hello first sh Shell File is not created .. done
【问题讨论】:
-
简短的回答是“是的,你可以”。对于与您的具体情况相关的答案,您需要提供实施的具体细节。
-
嗨...我已经更新了详细信息。你能检查一下并告诉我我必须做些什么改变吗?感谢您的宝贵时间。