简体   繁体   English

通过jsp表单在centos 5中创建用户

[英]Create a user in centos 5 from a jsp form

I have a form which sends by post method registration.jsp file, first saved in the database and then must open a "command.sh": 我有一个表单,该表单通过邮寄方法发送registration.jsp文件,该文件首先保存在数据库中,然后必须打开“ command.sh”:

<%@ page import ="java.sql.*,java.io.*"%>
<%
   String user = request.getParameter("uname");    
    String pwd = request.getParameter("pass");
      Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp",
            "root", "");
    Statement st = con.createStatement();

    int i = st.executeUpdate("insert into members(uname, pass, regdate) values ('" + user + "','" + pwd + "', CURDATE())");

  Process p=Runtime.getRuntime().exec("./command.sh "+user+pwd);
        if (i > 0) {
              response.sendRedirect("welcome.jsp");
     } else {
        response.sendRedirect("index.jsp");
    }

I am using the following code, but when I run it I get an error: 我正在使用以下代码,但是在运行它时出现错误:

Error 错误

Files 档案

Yes save in the database. 是的,保存在数据库中。 I also do not know how to create a Unix user by receiving the data I sent from the jsp. 我还不知道如何通过接收从jsp发送的数据来创建Unix用户。

Please Help Me 请帮我

Try using ServletContext.getRealPath() , for example: 尝试使用ServletContext.getRealPath() ,例如:

String fullPath = application.getRealPath("command.sh");
String[] cmd = { fullPath + " " + user + pwd };
Process p = Runtime.getRuntime().exec(cmd);

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

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