down123321123 2013-11-04 15:10
浏览 41

如何将php变量导入linux脚本?

I'm trying to work out how to get variables from php into a script because I want to create a user registration page so users can register and the php will call a script and send the variables to it.

Specifically this line i'm having trouble with (its in the php page):

PHP: $results = bash /home/*******/public_html/add_user $login '$pwd';

add_user.sh:

#!/bin/bash
adduser -u "$1" -p "$2" -g users -s /bin/bash
  • 写回答

3条回答 默认 最新

  • douji1853 2013-11-04 15:19
    关注

    exec

    $results = exec("bash /home/*******/public_html/add_user $login '$pwd'");
    

    Keep in mind that the user running this process (the web user, probably www-data, www, web, etc.) must have sudo or elevated access to do this. I would also like to caution against doing this unless you've really taken the time to consider all implications and consequences if you are exposing this to the web.

    评论

报告相同问题?