-1

I am trying to execute a java program form my ruby code.

My code is something like:

    cmd = "java -cp \"path/lib/*\" com.blah.blah"


#    %x[#{cmd}]
#    `#{cmd}`
#    Kernel.system(cmd)
    Kernel.exec(cmd)

My problem, is the command does not run successfully in either way. I know that %x, backticks runs in a subshell so probably some env variables are missing. However I was hoping for Kernel.system, Kernel.exec to succeed.

The command runs fine if I directly type it in a shell. Any help in debugging this ?

Thanks!

philant
  • 34,748
  • 11
  • 69
  • 112
codeObserver
  • 6,521
  • 16
  • 76
  • 121
  • Add a redirection of all output (stdout and stderr) of the command to a file in `cmd`, and post it here. – philant Dec 01 '11 at 10:37

1 Answers1

0

Turns out the issue was I was not closing the files I was creating.

Apparently that was fine when I was invoking it directly from the shell or directly from .sh, because the ruby script had already exited.

However when I would invoke this from the Ruby script it would not be able to access the file and would create issues.

Bottom line: Close your files else loose half day of work !

codeObserver
  • 6,521
  • 16
  • 76
  • 121