build.jl
run(`sudo -S mkdir test`)
当您运行Pkg.build("TestBuild")
时,您将无法输入密码。
julia> Pkg.build("TestBuild")
INFO: Building TestBuild
[sudo] password for guo:
==============================[ ERROR: TestBuild ]==============================
LoadError: failed process: Process(`sudo -S mkdir test`, ProcessExited(1))
此演示程序包TestBuild
位于Github。
如何在build.jl中使用sudo
?
答案 0 :(得分:1)
run(`mkfifo /tmp/pwd-fifo`)
prompt = "sudo need your password, please run [read -s p && echo \$p > /tmp/pwd-fifo] in another shell.\n\
"
sudo = @async run(`bash -c "sudo -S -p '' touch /tmp/tx < /tmp/pwd-fifo"`)
print(prompt)
wait(sudo)
以上代码由KDr2
提供