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 Executing shell scripts & batch files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Executing shell scripts & batch files" Watch "Executing shell scripts & batch files" New topic
Author

Executing shell scripts & batch files

sekhar variam
Greenhorn

Joined: Nov 09, 2001
Posts: 15
Hi all
I want to execute a daemon process from a java program. but Runtime.getRuntime.exec(scriptName) is not starting the process., where the scriptName is a batch file in NT and a shell script in Unix. There are no exceptions also thrown..The same works well when I am passing and exe file say Notepad.exe in place of the daemon process script name
Thanks in advance
Sekhar


SCJP4(96%)
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Try using something like this:
Runtime.getRuntime().exec("cmd /K start run.bat");
Runtime.getRuntime().exec("cmd /K del run.bat");
(You can look in Windows help under cmd or command for the /K and /c options)


"JavaRanch, where the deer and the Certified play" - David O'Meara
sekhar variam
Greenhorn

Joined: Nov 09, 2001
Posts: 15
Thanks a lot Cindy..Its working now. ..I hope something similar works for shell scripts also...
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
I am no Unix person - but I think that the syntax is almost the same . . .
There is a cmd.exe in unix (don't know about the options).
Try: (cmd start whatever.sh)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing shell scripts & batch files