运行 来自 scala 的自定义外部命令

Run custom external command from scala

我正在尝试将 torch 与 scala 集成。

我有以下 bash 脚本 (foo.sh):

#!/bin/bash
echo hello world
th *rest of command*

我尝试在 scala 中执行它以获得一些输出:

"./foo.sh" !!

但是它给了我一个错误:

line 42: th: command not found

是否有任何解决方法可以使它正常工作?

你有安装pytorch吗? 如果是,试试这个:

#!/bin/bash
source ~/.profile
source ~/.bashrc
echo hello world
th *rest of command*

或更好 运行 th 完整路径。完整路径可以通过命令获取:

type th

我建议将完整路径添加到 th