Julia 运行/管道命令翻译 [英] Julia run/pipeline command translation

查看:44
本文介绍了Julia 运行/管道命令翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆