Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Execute external program from tomcat servlet
I want to execute external programs (in this case batch-files)
server-side, and capture the output. I've read about Runtime.exec and
the different problems with reading the input stream.
Despite having tried a bunch of examples, I haven't been able to get
any of them to work when executed by tomcat (running as a service on
win2003svr, user "local system account" ).
As a stand-alone java program there is no problem executing the
batch-file. What could be the cause of my problem?

Report this thread to moderator Post Follow-up to this message
Old Post
Fredrik
09-29-04 02:28 AM


Re: Execute external program from tomcat servlet
On 28 Sep 2004 14:46:07 -0700, Fredrik wrote:

> ...What could be the cause of my problem?

<with head tilted>
To fix that NotEnoughFluffyKittensException,
simply use the web-context cats='letthembreed'.
</with head tilted>

If that does not fix the problem, you might try
stating exactly what the exception or error is.
<http://www.physci.org/codes/javafaq.jsp#exact>

I would also be helpful if you provide a self-contained
example of your code that does not work.
<http://www.physci.org/codes/sscce.jsp>

--
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Thompson
09-29-04 02:28 AM


Re: Execute external program from tomcat servlet
I didnt't get an exception. That would make things alot easier.
I didn't include any code since i've tried almost every example that i
could find, with the same result: _nothing happens_  The external
program never seems to get executed.
I've tried everyting from simple ones like

try {
String line;
Process p = Runtime.getRuntime().exec(cmdline);
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
}
catch (Exception err) {
err.printStackTrace();
}
}

,to complete multi-threaded helper classes such as
http://www.codeproject.com/useritems/ProcessHelper.asp

Both of them works splendid when executed as standalone java, but not
from tomcat.
I didn't include them because i thought this was a "theroretical"
problem with running external programs from java programs running as a
windows service, not a code-error.

Please excuse my bad English.



Andrew Thompson <SeeMySites@www.invalid> wrote in message news:<4h8zgxq9029i.pesjrbphczig$.
dlg@40tude.net>...
> On 28 Sep 2004 14:46:07 -0700, Fredrik wrote:
> 
>
> <with head tilted>
> To fix that NotEnoughFluffyKittensException,
> simply use the web-context cats='letthembreed'.
> </with head tilted>
>
> If that does not fix the problem, you might try
> stating exactly what the exception or error is.
> <http://www.physci.org/codes/javafaq.jsp#exact>
>
> I would also be helpful if you provide a self-contained
> example of your code that does not work.
> <http://www.physci.org/codes/sscce.jsp>

Report this thread to moderator Post Follow-up to this message
Old Post
Fredrik
09-29-04 10:00 AM


Re: Execute external program from tomcat servlet
On 28 Sep 2004 23:32:07 -0700, Fredrik wrote:
> Andrew Thompson <SeeMySites@www.invalid> wrote in message news:<4h8zgxq902
9i.pesjrbphczig$.dlg@40tude.net>... 
.. 

> I didnt't get an exception. That would make things alot easier.
> I didn't include any code since i've tried almost every example that i
> could find, with the same result: _nothing happens_  The external
> program never seems to get executed.
> I've tried everyting from simple ones like
>
>   try {

Put something there that is 'self-contained' and I will try it..
...
> http://www.codeproject.com/useritems/ProcessHelper.asp

Wants a log-in..

> Both of them works splendid when executed as standalone java, but not
> from tomcat.

Logs!

> I didn't include them because i thought this was a "theroretical"
> problem with running external programs from java programs running as a
> windows service, not a code-error.

I do not know enough to say, but you are going to need
to get the server gurus in on this one.

> Please excuse my bad English.

You're English is fine, but please make sure you read the
URL's I give you, the code you supplied above was not what
I described in the link.

--
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Thompson
09-29-04 04:03 PM


Re: Execute external program from tomcat servlet
quote:
Originally posted by Fredrik I want to execute external programs (in this case batch-files) server-side, and capture the output. I've read about Runtime.exec and the different problems with reading the input stream. Despite having tried a bunch of examples, I haven't been able to get any of them to work when executed by tomcat (running as a service on win2003svr, user "local system account" ). As a stand-alone java program there is no problem executing the batch-file. What could be the cause of my problem?

Report this thread to moderator Post Follow-up to this message
Old Post
garollous
11-22-05 12:21 AM


Re: Re: Execute external program from tomcat servlet
Hi,
I am having the same issue now. Can you please let me know if we can execute
 batch file if tomcat is started as a service
Thanks for your help.

Report this thread to moderator Post Follow-up to this message
Old Post
garollous
11-22-05 12:23 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:39 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.