문제

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!

도움이 되었습니까?

해결책

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 !

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top