我正在使用:
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String Ip = request.getRemoteAddr();
System.out.println("IP " + Ip);
processRequest(request, response);
}
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String name = request.getParameter("name");
out.println("<h3>You have entered name : "+name+"<br>");
out.println("<b><font color='blue'>IP Address of request : </font></b>" + request.getRemoteAddr() + "</h3>");
System.out.println("<h3>You have entered name : " + name + "<br>");
System.out.println("<b><font color='blue'>IP Address of request : </font></b>" + request.getRemoteAddr() + "</h3>");
}
..返回用户的IP地址,我需要将其存储为变量并使用以下变量:
public void setRc(String rc) throws IOException { //need to start/call doGet() and/or processRequest() here....
try {
Process d = Runtime.getRuntime().exec("c:\\commands\\psexec \\\\" + Ip + " -i -s -d \"C:\\Program Files (x86)\\Microsoft Configuration Manager Console\\AdminUI\\bin\\i386\\rc.exe\" 1 " + rc);
} catch (Exception e) {
System.out.println("FROM CATCH " + e.toString());
this.rc = rc;
}
}
这是针对我们IT团队的Web应用程序 - 在用户端打开远程连接gui - 并且它将目标pc作为rc之后的变量。
因此,命令将是:psexec - 在Web应用程序用户桌面上,参数xyz并在目标PC上运行rc.exe ...
它的工作方式:用户输入与1.)用户,2。)pc或3.)ID#的信息(进入Web应用程序) - 然后他们点击提交按钮... 然后...信息返回到屏幕(从SQL) 然后......计算机名称被放入命令行(作为rc - 在.java页面中),Web应用程序显示远程命令的可能性 - 作为按钮.... 例如“单击按钮在PC名称xxx-xxxxxx上执行abc.exe
因此,我需要将IT组用户的IP地址合并到命令行中......
注意:在目标上运行命令很简单bc - 服务器打开cmd并执行psexec以在目标上执行.exe 但是,在此示例中,服务器需要在用户上运行cmd - 在用户pc上打开gui - 目标pc设置为rc.exe中的参数...
所以......例子就是:用户 - &gt;服务器 - &gt;目标 和......示例两:用户 - &gt;服务器 - &gt;用户 - &gt;目标
谢谢。
这是按钮 - 启动setRun:
<td>
<form name="rc" action="index.jsp" />
Remote Control:<input type="submit" value="${UserDetails.Computer_Name}" onsubmit=jsp:setProperty name="rc"/>
</form>
</td>