Julia的run
函数似乎难以运行source
。奇怪的是,如果我在shell中运行完全相同的命令,它就没有问题。
有没有办法以编程方式从Julia运行命令?
julia> cmd = "/home/me/tensorflow/bin/activate"
"/home/me/tensorflow/bin/activate"
julia> run(`ls $cmd`)
/home/me/tensorflow/bin/activate
julia> run(`source $cmd`)
ERROR: could not spawn `source /home/me/tensorflow/bin/activate`: no such file or directory (ENOENT)
in _jl_spawn at process.jl:262
in anonymous at process.jl:415
in setup_stdio at ./process.jl:403
in __spawn#58__ at ./process.jl:414
in run at ./process.jl:530
shell> source /home/me/tensorflow/bin/activate
答案 0 :(得分:3)
source是内置命令
尝试这样:
run(`zsh -c "source $cmd"`)
run(`bash -c source $cmd`)
窗口:
run(`cmd /c 'echo xxx'`)