如何通过网站执行带有 php 的 .sh 文件
How to execute .sh file with php via website
我正在尝试通过网站从 .php 文件执行文件
我首先尝试:
<?php
exec('bash create_user.sh '.$_POST['password'].' '.$_POST['username']);
exec('bash create_user.sh 123456 user');
?>
什么也没做!
第二个正在尝试:
<?php
shell_exec('bash create_user.sh '.$_POST['password'].' '.$_POST['username']);
shell_exec('bash create_user.sh 123456 user');
?>
什么也没做!
我该怎么做。谢谢。
在你的 sh 中添加为第一行
#!/bin/sh
然后像这样调用 php
if(isset($_POST['password']) && isset($_POST['username'])) {
shell_exec('./create_user.sh '. $_POST['password'] . ' ' . $_POST['username']);
} else {
echo 'You must send user and pass';
}
并授予 Web 服务器用户 write/execute 权限。
我正在尝试通过网站从 .php 文件执行文件
我首先尝试:
<?php
exec('bash create_user.sh '.$_POST['password'].' '.$_POST['username']);
exec('bash create_user.sh 123456 user');
?>
什么也没做!
第二个正在尝试:
<?php
shell_exec('bash create_user.sh '.$_POST['password'].' '.$_POST['username']);
shell_exec('bash create_user.sh 123456 user');
?>
什么也没做!
我该怎么做。谢谢。
在你的 sh 中添加为第一行
#!/bin/sh
然后像这样调用 php
if(isset($_POST['password']) && isset($_POST['username'])) {
shell_exec('./create_user.sh '. $_POST['password'] . ' ' . $_POST['username']);
} else {
echo 'You must send user and pass';
}
并授予 Web 服务器用户 write/execute 权限。