# Capture CMD output in Julia

**URL:** <https://discourse.julialang.org/t/capture-cmd-output-in-julia/26503>\
**Category:** New to Julia\
**Created:** [July 18, 2019, 3:12pm UTC](https://discourse.julialang.org/t/capture-cmd-output-in-julia/26503 "2019-07-18T15:12:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [July 18, 2019, 3:12pm UTC](https://discourse.julialang.org/t/capture-cmd-output-in-julia/26503/1 "2019-07-18T15:12:26Z")

</div>

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:

```julia
## 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
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

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [July 18, 2019, 3:16pm UTC](https://discourse.julialang.org/t/capture-cmd-output-in-julia/26503/2 "2019-07-18T15:16:12Z")

</div>

[https://docs.julialang.org/en/v1/manual/running-external-programs/index.html](https://docs.julialang.org/en/v1/manual/running-external-programs/index.html)

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

```

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [July 18, 2019, 3:16pm UTC](https://discourse.julialang.org/t/capture-cmd-output-in-julia/26503/3 "2019-07-18T15:16:47Z")

</div>

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

Thank you!
