Capture CMD output in Julia

Hey guys

I am trying to use Julia in connection with CMD, so that I can do some fancy stuff. I just have a bit of starting problems, since I do not understand how to capture my cmd output. For an example let us look at this code:

## Simple Example

mycommand = `cmd /c date /t`

a = run(mycommand)

I am running a cmd command to get the current date and then trying to save the output of this command, in a. Unfortunately what I get is:

julia> a
Process(`cmd /c date /t`, ProcessExited(0))

Which is wrong, when I want a = 18-07-2019 etc.

In the past it seems like something like “readall” was used, but I can’t get it to work?

Hoping someone has had the same struggle and can help out

Kind regards

a = read(`cmd /c date /t`, String)

Yeah thanks, just found it as well, was going to delete but since you answered so fast I just gave you the solution :slight_smile:

Thank you!

1 Like