VileProtagonist
VileProtagonist

Reputation: 31

Julia - Substitute for readandwrite()

I am trying to open and write to an external application in Julia. From my research, I have found that there used to a function called readandwrite() that would do this task easily. However, it appears that that function was deprecated in an earlier release.

I have tried using the pipeline() command and run() to little success. I also tried opening it and writing to it with write() but write does not take an IOstream. I have been here and tried out the code snippets, but none seem to work. Others I do not know where to put the path of the file.

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

Where xPath is a string containing the path to the file ("xfoil.exe") This code returns an unknown error and that it could not spawn the executable file. Any help would be appreciated as I have hit a wall with opening this file. Thanks.

Upvotes: 0

Views: 231

Answers (1)

fredrikekre
fredrikekre

Reputation: 10984

Running on Julia 0.7 you get this warning:

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.

So the replacement is:

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

and then use read and write on p.

Upvotes: 3

Related Questions