Run Command without Single Quote


I want Julia to run a command to 7-zip a file, i.e. following works in my terminal:

7z a c:\test\ c:\test\f1.txt

I have to use Double Quote or No Quote for the file name, otherwise, If I use Single Quote, 7 zip Output an Error

However, when I do this in Julia,

cc = `7z a c:\\test\\ c:\\test\\f1.txt`


This failed, because when I do

It generate this output:

7z a 'c:\test\' 'c:\test\f1.txt'

How come Julia added single quote around file name? I dont like it because it will break my 7-zip command. 7z only accept double quote or No quote.

Thank you



Have you tried it without the double quotes and using backslashes to escape the spaces?



I changed my example, it still does not work…



I’m pretty sure that’s just a printing thing (the single quotes). That command works fine for me:

julia> cmd = `7z a E:\\Downloads\\ E:\\Downloads\\foo`
`7z a 'E:\Downloads\' 'E:\Downloads\foo'`

julia> run(cmd)

7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04

Open archive: E:\Downloads\
Path = E:\Downloads\
Type = zip
Physical Size = 2412099
Comment = e16eaa0b8d8ccf3f432c9ef46cbbc6453789fce7

Scanning the drive:
1 folder, 0 files, 0 bytes

Updating archive: E:\Downloads\

Items to compress: 1

Files read from disk: 0
Archive size: 2412099 bytes (2356 KiB)
Everything is Ok
Process(`7z a 'E:\Downloads\' 'E:\Downloads\foo'`, ProcessExited(0))


I am using Windows 10 Enterprise + Julia 1.1 + 7-zip (2019-02-21) 64 bits

cc = `7z a c:\\temp\\ c:\\temp\\f1.txt`

IOError: could not spawn 7z a 'c:\temp\' 'c:\temp\f1.txt': no such file or directory (ENOENT)
_spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at process.jl:400
setup_stdios(::getfield(Base, Symbol("##505#506")){Cmd}, ::Array{Any,1}) at process.jl:413
_spawn at process.jl:412 [inlined]
#run#515(::Bool, ::Function, ::Cmd) at process.jl:725
run(::Cmd) at process.jl:724
top-level scope at none:0

Then I open a windows terminal
Without Single Quote, it works:

Adding Single Quote, it failed, exactly the same as Julia 's case

@pfitzseb Could you try this:

  1. In a windows command line, you try to add Single Quote to your file name, does it still work?
    i.e. you will run this in windows command line, not Julia REPL:

7z a 'E:\\Downloads\\' 'E:\\Downloads\\foo'

  1. If you upgrade you 7 zip to v19 or latest 2019-02 version, with 64-bit, does it still work?

Thank you



Those are different errors. I’m pretty sure Julia can’t find 7z for some reason, so try specifying the complete path (e.g. as joinpath(Sys.BINDIR, "7z") if you want to use the 7zip shipped with Julia).



Isn’t the latest problem that you have c: instead of C:?