是否有任何远程跨平台方式来执行外部进程?
我正在寻找有关如何执行跨平台流程的建议。
我已经编写了我的应用程序的 Java 和 Ruby 实现,但它不是特定于语言的问题,而是特定于平台的问题。
Ubuntu 上的 EG /usr/bin/ 会搜索我所做的任何事情
# Ruby
`HandBrakeCLI #{args}` # works on Ubuntu and likely other linux distros since HandBrakeCLI is in /usr/bin/
对于 Windows,它将搜索我正在运行的当前目录。但是,如果将 Windows 可执行文件复制到当前目录,则运行时链接错误将导致其崩溃(DLL 不 HandBrakeCLI 的默认
安装路径位于“Program Files(x86)/HandBrake”(显然 x86 仅在 64 位中),但是据我所知,Program Files 不在搜索路径中。
对于 MacOSX,除了使用“打开”命令之外,我不知道如何从命令行执行 Mac“应用程序文件夹”。但这不是什么问题,因为我真正想要的是 HandBrakeCLI,它只是一个普通的可执行文件。但是,HandBrakeCLI 未安装到 /usr/bin 或 /usr/local/bin (或其中的任何变体)
我最好的想法是创建一个包含 HandBrakeCLI 路径的配置文件。然而,如果我走这条路,最好能够检测到我所在的平台,但这是另一个问题。我只用 C #ifdef 部分完成了其中一项,而不是在 Ruby 或 Java 中完成。
我将不胜感激任何和所有的意见。
I was looking for advice on how to execute a process that is somewhat cross platform.
I have written Java and Ruby implementations of my app, but its less of a language specific problem and more of a platform specific issue.
E.G on Ubuntu /usr/bin/ is searched for anything I do
# Ruby
`HandBrakeCLI #{args}` # works on Ubuntu and likely other linux distros since HandBrakeCLI is in /usr/bin/
For windows it will search the current directory I am running in. However, If copy the windows executable to the current directory a runtime linking error will cause it to crash (DLL not present)
The default install path for HandBrakeCLI is in "Program Files(x86)/HandBrake" (x86 only in 64 bit obviously), however Program Files isn't in the search path as far as I can tell.
For MacOSX I have no clue how to execute Mac "Application Folders" from the command line other than with the "open" command. But that is less of an issue since what I am really after is HandBrakeCLI which is just a normal executable. However HandBrakeCLI is not installed to /usr/bin or /usr/local/bin ( or any variation there of )
My best idea is to make a config file that has the path to HandBrakeCLI. If I go that route however it would be ideal to be able to detect what platform I am on, but that is another problem all together. One I have only done with C #ifdef sections and not in Ruby or Java.
I would appreciate any and all input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
获取 Java 中的当前操作系统
您可以使用In ruby
:希望这会有所帮助:)
You can get the current OS in Java using
In ruby:
Hope this helps :)