简体   繁体   中英

How to pass argument to shell script file from servlet

I am trying for GUI application where in I need to pass values to run shell script functions and these values are passed from JSP to Servlet and Servlet to shell file.

Can any one please suggest how to execute this?

Using the usual java way. Suppose parameter is param

String shCmd = "sh test.sh "+param;
Runtime rt = Runtime.getRuntime();
rt.exec(shCmd);

Take care of script path.
This code can be placed in jsp as well as servlet. Its just Java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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