File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes runtime.exec() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "runtime.exec()" Watch "runtime.exec()" New topic
Author

runtime.exec()

gireesh sivan
Greenhorn

Joined: Dec 15, 2006
Posts: 4
i am facing a problem in linux.

When i try to excecute a shell script using runtime.exec(),the script not exce cutting properly.The process is not completing.i am using jboss as application server.so the call for shell script is from jboss server.so i think jboss server is the problem here

because When i try to excecute script dirctly from linux,it working correctly .Also i try it using stand alone java class.Its working fine.

please help me to find a solution
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

... the script not exce cutting properly.The process is not completing.

Can you please explain exactly what you mean by this? What is happening? Does the script get called at all or not? Do you get an error message? If yes, then what is the error message?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


i am using jboss as application server.so the call for shell script is from jboss server.so i think jboss server is the problem here

Do you mean you are calling Runtime.exec() from an EJB?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
gireesh sivan
Greenhorn

Joined: Dec 15, 2006
Posts: 4
when i try to call runtime.exec(),the process will start and is not completing.i can see the process id.when i shutdown my jboss server,the process wiil complete.

eg: i am calling an shell script called uafimail.sh

the process will start i can see the process id of uafimail.sh.

when i shutdown my jboss server the process will complete.

Its only happends when the call is from jboss server.


i can excecute it from a standalone java program,also from linux prompt.

but the problem when its in jboss
gireesh sivan
Greenhorn

Joined: Dec 15, 2006
Posts: 4
no the call is not from ejb
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
The process is not completing.


That sure sounds like the typical problem you get if you do not provide for consuming the error output stream and standard output stream from the Process. Read the JavaDocs for java.lang.Process - where you will find a discussion of the problem.

Bill
gireesh sivan
Greenhorn

Joined: Dec 15, 2006
Posts: 4
i also provide error output stream and output stream.

But the problem still remaining
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
i also provide error output stream and output stream.

How are you reading those streams? Each stream must have a reader in its own thread, you can't just read one and then the other in the same thread.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: runtime.exec()
 
Similar Threads
handling Java child process execution
Transfer of files thro. Linux 7.x
Runtime.exec problems with servlets.
call java program from script?
Unable to start Jboss-eap server from ANT script