简体   繁体   English

如何通过网站用php执行.sh文件

[英]How to execute .sh file with php via website

I'm trying to exec file from .php file via website 我正试图通过网站从.php文件执行文件

First am trying : 首先我在尝试:

<?php

exec('bash create_user.sh '.$_POST['password'].' '.$_POST['username']);

exec('bash create_user.sh 123456 user');

?>

And nothing done! 什么都没做!

Secound am trying : Secound正在尝试:

<?php

shell_exec('bash create_user.sh '.$_POST['password'].' '.$_POST['username']);

shell_exec('bash create_user.sh 123456 user');

?>

And nothing done! 什么都没做!

how can I do this. 我怎样才能做到这一点。 thnx. 日Thnx。

in your sh add as first line 在你的sh添加作为第一行

 #!/bin/sh

then call in php like this 然后像这样在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';
    }

And give to the web server user write/execute permissions. 并赋予Web服务器用户写入/执行权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM