In Julia 1.4, in Atom-IDE’s REPL, Windows, Julia and I have the following dialog
julia> run(`echo hello`)
ERROR: IOError: could not spawn `echo hello`: no such file or directory (ENOENT)
Stacktrace:
[1] _spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at .\process.jl:99
[2] #550 at .\process.jl:112 [inlined]
[3] setup_stdios(::Base.var"#550#551"{Cmd}, ::Array{Any,1}) at .\process.jl:196
[4] _spawn at .\process.jl:111 [inlined]
[5] run(::Cmd; wait::Bool) at .\process.jl:439
[6] run(::Cmd) at .\process.jl:438
[7] top-level scope at none:0
The command I type is straight from Julia’s manual, so I am baffled. Any idea?
I did open a cmd prompt, and echo hello worked wonders.
And your suggestion works.
So this means my first attempt sends a command to another shell, while yours sends a command to the same shell I opened?
One of these days it would be nice to get reasonable shell functionality on Windows by default. We’ve been back and forth on many different possible solutions, but the simplest seems to be to ship with busybox and put that in the path: see this comment by @StefanKarpinski.
Not really: Julia doesn’t use a shell to run a program. It just runs the program directly.
With
run(`echo hello`)
you ask Julia to execute the program echo (Windows will look for echo.exe, echo.com, etc.) with argument hello. This program exists on Linux but not on Windows.
With
run(`cmd /k echo hello`)
you ask Julia to execute the program cmd with arguments /k, echo and hello. The program cmd.exe is actually a shell so that will execute a shell