朱莉娅-代替readandwrite()

时间:2019-04-03 04:46:31

标签: pipe julia stdin

我正在尝试打开并写入Julia中的外部应用程序。从我的研究中,我发现曾经有一个名为readandwrite()的函数可以轻松完成此任务。但是,该功能似乎在较早的版本中已被弃用。

我尝试使用pipeline()命令和run()几乎没有成功。我也尝试打开它并使用write()对其进行写入,但是write不会占用IOstream。我已经here并尝试了代码片段,但似乎都没有用。其他人我不知道将文件的路径放在哪里。

p=open(pipeline(`./$xPath`; stderr=Pipe()), "r") 
(Pipe(RawFD(-1) closed => RawFD(20) open, 0 bytes waiting), Process(`./$xPath`, ProcessExited(0)))

其中xPath是包含文件路径的字符串(“ xfoil.exe”) 此代码返回未知错误,并且它无法产生可执行文件。 任何帮助将不胜感激,因为我在打开此文件时遇到了麻烦。 谢谢。

1 个答案:

答案 0 :(得分:2)

在Julia 0.7上运行时,您会收到以下警告:

julia> readandwrite(`ls`)
[ Warning: `readandwrite(::Cmd)` is deprecated in favor of `open(::Cmd, "r+").
[ You may read/write the returned process object for access to stdio.

因此替换为:

p = open(`ls`, "r+")

,然后在read上使用writep