Julia 运行/管道命令翻译 [英] Julia run/pipeline command translation
问题描述
我在使用 run/pipeline 命令时遇到了一些问题,我不确定我哪里出错了.我的目标是附加到日志并重定向 STDERR,以便错误将在日志中.与我想要运行的命令行等效(在终端运行时有效)如下:
I'm having some trouble with the run/pipeline commands and I'm not exactly sure where I'm going wrong. My goal is to append to a log and redirect STDERR so that errors will be in the log. The command line equivalent of what I want to run (which works when run at the terminal) is the following:
/home/me/juliaScripts/runjob.jl $three $one $one >> /home/me/dailylog.txt 2>&1
我在朱莉娅做什么:
runstring=`/home/me/juliaScripts/runjob.jl $three $one $one`
run(pipeline(runstring,stdout="/home/me/dailylog.txt",stderr="/home/me/dailylog.txt",append=true))
我得到的错误是:错误:管道未定义有没有更好的方法来使用 run 命令来实现我想要的(附加到日志并重定向 STDERR)?非常感谢.
The error I'm getting is : ERROR: pipeline not defined Is there a better way to use the run command to achieve what I want (appending to a log and redirecting STDERR)? Thanks so much.
推荐答案
有一个元解决方案可以运行等效于 shell 命令,它是在 shell 中运行它.对于给出的示例:
There is a meta solution for running the equivalent of a shell command and it is to run it in a shell. For the example given:
bashcmd = "/home/me/juliaScripts/runjob.jl $three $one $one >> /home/me/dailylog.txt 2>&1"
run(`/bin/bash -c $bashcmd`)
这应该可以在 0.3 版中使用,但是 /bin/bash
可能需要替换为不同的路径(取决于您正在运行的 shell).此外,$three $one $one
需要更仔细地转义(如果它们是简单的字母数字词应该没问题).
This should work in version 0.3, but the /bin/bash
may need to be replaced with a different path (depending on the shell you are running). Additionally, the $three $one $one
need to be more carefully escaped (if they are simple alphanumeric words it should be OK).
这篇关于Julia 运行/管道命令翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!