wood burning stoves 2.0*
The moose likes Java in General and the fly likes calling Unix script from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "calling Unix script from Java" Watch "calling Unix script from Java" New topic
Author

calling Unix script from Java

Sandeep Advani
Ranch Hand

Joined: Mar 11, 2004
Posts: 78
Hi

Code snippet is -



I get this exception...

Start compiling ....
Command is source CompileAgent.sh TestClient
Check point 1
Caught an IO exception
java.io.IOException: java.io.IOException: source: not found
at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at CompileJava.doWork(CompileJava.java:19)
at CompileJava.main(CompileJava.java:50)
Exception in thread "main" java.lang.NullPointerException
at CompileJava.doWork(CompileJava.java:41)
at CompileJava.main(CompileJava.java:50)

Says source not found but the command runs well when I run this from
the shell prompt.

Thanks again
Sandeep
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
"source" is a C-shell command (ok, maybe other shells that I'm not familiar with too). Under Unix Java will call the native fork()/exec() of the platform. Under Solaris this is "/bin/sh". Under Linux I think it is "/bin/ksh" but don't hold me to that. Therefore, you will want to do something like:



<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
 
Don't get me started about those stupid light bulbs.
 
subject: calling Unix script from Java
 
Similar Threads
running OS commands in Java
Process
Pesky Runtime method
Running DOS commands
Runtime.exec()