run a sh file using JSP

Can somebody provide an idea for me to implement a web page using jsp that enable me to run a sh file through internet? I need to remotely run a sh file which are located in a unix server through the created jsp page. TQ
[227 byte] By [ccwoon80a] at [2007-11-26 20:01:57]
# 1
try using Process and Runtime class to call your shell script.
dfkljadkfljdfla at 2007-7-9 23:00:49 > top of Java-index,Java Essentials,New To Java...
# 2

Actually ,i had use Process and Runtime class to create a jar file. I invoke the jar file in my jsp page. But, it does not work! Below is my class file and jsp file:

java class file:

package serveradmin;

/*

*

* Created on February 28, 2007, 10:32 AM

*/

import java.util.*;

import java.io.*;

public class Main

{

static class PipeInputStreamToOutputStream implements Runnable

{

PipeInputStreamToOutputStream(InputStream is, OutputStream os)

{

is_ = is;

os_ = os;

}

public void run()

{

try

{

byte[] buffer = new byte[1024];

for(int count = 0; (count = is_.read(buffer)) >= 0;)

{

os_.write(buffer, 0, count);

}

}

catch (IOException e)

{

e.printStackTrace();

}

}

private final InputStream is_;

private final OutputStream os_;

}

public void runSH()

{

try

{

String dir = System.getProperty("user.home");

String[] command = {"sh","-c", "./mk.sh"};

final Process process = Runtime.getRuntime().exec(command);

new Thread(new PipeInputStreamToOutputStream(process.getInputStream(), System.out)).start();

new Thread(new PipeInputStreamToOutputStream(process.getErrorStream(), System.err)).start();

int returnCode = process.waitFor();

System.out.println("Return code = " + returnCode);

}

catch (Exception e)

{

e.printStackTrace();

}

}

}

jsp file:

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<jsp:useBean class="serverAdmin.Main" id="serverAdmin" scope="session"/>

<html>

<head><title>Index JSP</title></head>

<body>

<%serverAdmin.runSH();%>

</body>

</html>

mk.sh:

mkdir test/test.txt

Thus, can u kindly show me an eample?

TQ for the reply. :)

ccwoon80a at 2007-7-9 23:00:49 > top of Java-index,Java Essentials,New To Java...
# 3
and what "does not work"?"it" doesn't tell anything to anyone.Most likely you simply don't have permission to do what you want to do, as most systems will disallow webservers from disc access outside their own web application context(s).
jwentinga at 2007-7-9 23:00:49 > top of Java-index,Java Essentials,New To Java...
# 4
String[] command = {"sh","-c", "./mk.sh"};Is the script in the working directory? Do you know actually what the working directory is?
BIJ001a at 2007-7-9 23:00:49 > top of Java-index,Java Essentials,New To Java...