# Why does the command \`run\` fails in this example from the documentation?

**URL:** <https://discourse.julialang.org/t/why-does-the-command-run-fails-in-this-example-from-the-documentation/70686>\
**Category:** General Usage\
**Created:** [October 31, 2021, 1:24pm UTC](https://discourse.julialang.org/t/why-does-the-command-run-fails-in-this-example-from-the-documentation/70686 "2021-10-31T13:24:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Post date:** [October 31, 2021, 1:24pm UTC](https://discourse.julialang.org/t/why-does-the-command-run-fails-in-this-example-from-the-documentation/70686/1 "2021-10-31T13:24:45Z")

</div>

I am trying to learn how to issue shell commands from my Julia program. My OS is Windows 10 but I would also like the commands to run under Linux (Kubuntu). I found the following in the documentation:

```julia
julia> mycommand = `echo hello`
`echo hello`

julia> typeof(mycommand)
Cmd

julia> run(mycommand);
hello

```

The two first commands run as displayed above, but when I try the last one I get the following:

```julia
julia> run(mycommand);
ERROR: IOError: could not spawn `echo hello`: no such file or directory (ENOENT)
Stacktrace:
 [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Any})
   @ Base .\process.jl:99
 [2] #637
   @ .\process.jl:112 [inlined]
 [3] setup_stdios(f::Base.var"#637#638"{Cmd}, stdios::Vector{Any})
   @ Base .\process.jl:196
 [4] _spawn
   @ .\process.jl:111 [inlined]
 [5] run(::Cmd; wait::Bool)
   @ Base .\process.jl:439
 [6] run(::Cmd)
   @ Base .\process.jl:438
 [7] top-level scope
   @ REPL[19]:1

julia>

```

I would like to understand why this happened, and more generally how to issue Windows command prompt commands like `dir`, `md`, `cd`, etc. from inside my Julia program. Same for Linux.

Any help will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![woclass](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/woclass/32/212699_2.png) [@woclass](https://discourse.julialang.org/u/woclass)\
**Post date:** [October 31, 2021, 1:32pm UTC](https://discourse.julialang.org/t/why-does-the-command-run-fails-in-this-example-from-the-documentation/70686/2 "2021-10-31T13:32:22Z")

</div>

Maybe

```julia
; cmd /c echo hello

```

```julia
julia>

shell> cmd /c echo hello
hello

```

> The following assumes a Posix environment as on Linux or MacOS. On Windows, many similar commands, such as `echo` and `dir` , are not external programs and instead are built into the shell `cmd.exe` itself. One option to run these commands is to invoke `cmd.exe` , for example `cmd /C echo hello` . Alternatively Julia can be run inside a Posix environment such as Cygwin.

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

> <https://github.com/JuliaLang/julia/issues/23597>
>
> I know that this is not the fault of Julia, but the Windows shell does not pl…ay nicely with Julia in the "shell mode". For instance, typing \`; dir\` will result in an error because this is not a command executed by program. This applies to most of the commands available in the Windows shell. So far I found only \`tree\` and \`help\` to work...
> 
> It would probably prevent some useless experimentation and disappointments for new users if this fact was clearly mentioned in the documentation: the "shell mode" does not work in Windows.
