[英]User can create file or folder but restricted to delete in centos-8
[英]Create a user in centos 5 from a jsp form
我有一个表单,该表单通过邮寄方法发送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");
}
我正在使用以下代码,但是在运行它时出现错误:
是的,保存在数据库中。 我还不知道如何通过接收从jsp发送的数据来创建Unix用户。
请帮我
尝试使用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.