I am trying to call a fan command from a Fantom process. This is the error it runs from Fantom, it runs correctly from the command line. What do you think the problem could be?
class Main {
Void main() {
buf := Buf()
Process() {
command = ["fan <pod>::<type>.<method>"]
out = buf.out
}.run.join
outStr := buf.flip.readAllStr
}
}
This is the error I am getting:
sys::IOErr: java.io.IOException: Cannot run program "fan <pod>::<type>.<method>":
CreateProcess error=2, The system cannot find the file specified
java.lang.ProcessBuilder.start (Unknown)
fan.sys.Process.run (Process.java:141)
PDFCommandLine::Main.main (Main.fan:10)
java.lang.reflect.Method.invoke (Unknown)
fan.sys.Method.invoke (Method.java:559)
fan.sys.Method$MethodFunc.callOn (Method.java:230)
fan.sys.Method.callOn (Method.java:139)
fanx.tools.Fan.callMain (Fan.java:185)
fanx.tools.Fan.executeType (Fan.java:147)
fanx.tools.Fan.execute (Fan.java:41)
fanx.tools.Fan.run (Fan.java:308)
fanx.tools.Fan.main (Fan.java:346)
I think the issue is that there is no Windows file called
fan, onlyfan.bat!It is only the Windows command prompt that interpolates
fanand looks for executable extensions,.com,.bat,.cmd,.exe, etc...Note experience with the BedSheet proxy tells me that the new
fan.batlaunches Java in separate process and the batch file finishes straight away; so you don't actually receive any output from theProcessclass, even though the Fantom program ran successfully.Instead you need to compose a command that launches the Java process yourself. Something like:
Here's a little snippet that does just that in a cross-plaform manner:
And you can use like this:
Note the above requires
javato be on yourPATH.