You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Randy Layman <ra...@aswethink.com> on 2001/04/16 17:20:30 UTC

RE: How can I run Batch file from servlet ??

	When you create a process like this, its up to you to read and write
to the process.  This means that any output from your batch file will be
lost unless you deal with is (Process has methods to get the input and
output streams for standard in/out/error).

	I would suggest you try running your batch file from the tomcat's
home directory.  The problem is usually one of two things.  Either you have
relative paths which aren't valid in the current context or you are
expecting environment variables that aren't valid.  (Or possibly its
actually working but you aren't catching the batch file's input to know
that).

	Randy


> -----Original Message-----
> From: Sunil Chandurkar [mailto:sunil@nagpurcity.net]
> Sent: Monday, April 16, 2001 11:47 AM
> To: tomcat-user@jakarta.apache.org
> Subject: How can I run Batch file from servlet ??
> 
> 
> Hello All !! 
> 
> I am in big trouble, i want to call batch file on the server 
> from the servlet. I have tried the following option but they 
> didn't work.. please let me know if is there any way to do it... 
> 
> Process p = Runtime.getRuntime().exec 
> ("cmd D:\\myFolder\\myBatchFile.bat"); 
> p.waitFor(); 
> 
> also i have tried without cmd option: 
> Process p = Runtime.getRuntime().exec 
> ("D:\\myFolder\\myBatchFile.bat"); 
> p.waitFor(); 
> 
> Its not throwing an exception and not even giving me any output.. 
> 
> Thanx in Advance...
> 
> /sunil 
> 
> 
> 
> _____________________________________________________________
> Get LifeTime Free email Visit  ---> http://www.nagpurcity.net
>