【发布时间】:2018-12-19 06:26:58
【问题描述】:
当我在终端中编写命令./test.sh testvalue 时
它正在使用 sed 在脚本中编写“testvalue”。
但是当它使用 php shell_exec('./test.sh testvalue') 运行时
php脚本在页面上写hello(因为在bash中,我使用了echo)
但是 bash 脚本没有在 test.txt 数据中写入 testvalue。
为什么?
我在 php 和 bash 中使用了 chmod a+x+r?
请帮我!
谢谢!
我的 PHP:
<?php
session_start();
$out = shell_exec('./test_sed.sh $test');
echo "$out";
?>
我的狂欢:
#!/bin
new_pw=$1
sudo sed -i '/^wpa_passphrase/d' test.txt
sudo sed -i '$awpa_passphrase='$new_pw test.txt
echo 'hello'
【问题讨论】:
-
对不起$test,我当然在使用test,但它也不起作用!
-
您是否尝试为文件设置显式路径?
-
.对您的 PHP 脚本意味着什么?指定脚本的完整路径。 -
是的,.是否可以运行 bash 脚本
-
检查 php 是否在不同的路径中执行...在您的网络服务器文档根 e 中可能有一个
test.txt。 g.