----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
I agree with Fernando, it's probably a permissions problem. Often, I've
found that capturing the output from the error stream of the process is
helpful. Otherwise you may be blind as to what the actual error is. Also,
standard output may give you some useful messages. Here is sample code we
use to execute a unix script and print out everything from the error stream.
String command = { "/bin/csh", "-c",
"/some/dir/scriptname" }
Process child = Runtime.getRuntime().exec(command);
// Wait for process to finish.
try {
child.waitFor();
}
catch(InterruptedException e) {}
// Print out error messages.
BufferedReader childin = new BufferedReader(new
InputStreamReader(child.getErrorStream()));
String line = "";
while ((line = childin.readLine()) != null)
out.println(line + "<br>");
childin.close();
Kevin
-----Original Message-----
From: Hiren Shah <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
<[EMAIL PROTECTED]>
Date: Thursday, April 13, 2000 6:57 AM
Subject: Batch Script running problem in apache
>----------------------------------------------------------------
>BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
>WHEN YOU POST, include all relevant version numbers, log files,
>and configuration files. Don't make us guess your problem!!!
>----------------------------------------------------------------
>
>Hi
>
>I am using Apache Web Server .One of my servlets needs to execute a Batch
>script(unix).The code for Invoking the batch script is as follows ie
>
> try{
>
> Runtime myRuntime = Runtime.getRuntime();
> String sCommand,sPath;
> sPath="/usr/apache-d/htdocs/WebPages/Servlets/Admin/";
>
> sCommand = new String("sh " + sPath + "restart.bat");
> int iResult;
>
> iResult = myRuntime.exec(sCommand).waitFor();
> }
> catch(Exception e)
> {
> MyUtil.errorLog("Error in executing batch script");
> }
>
>
>where restart.bat is my shell script.
>When i try the above code in a normal java problem without apache web
server
>it runs fine and executes the shell script.
>
>Please tell how to call the batch script from a servlet invoked by the
>apache web server.
>
>regards
>Hiren
>
>
>
>
>--
>--------------------------------------------------------------
>Please read the FAQ! <http://java.apache.org/faq/>
>To subscribe: [EMAIL PROTECTED]
>To unsubscribe: [EMAIL PROTECTED]
>Archives and Other: <http://java.apache.org/main/mail.html>
>Problems?: [EMAIL PROTECTED]
>
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]