SingleFileZ icon indicating copy to clipboard operation
SingleFileZ copied to clipboard

Fix standard output redirect issue when running the Docker command in PowerShell

Open andrewdbate opened this issue 3 years ago • 4 comments

I have found some typos / inaccuracies on the following page that provides instructions for the CLI: https://github.com/gildas-lormeau/SingleFileZ/blob/master/cli/README.MD

The pages says:

Run and redirect the result into a file docker run singlefilez "https://www.wikipedia.org" > wikipedia.html

Whilst this might work on Linux/Mac, it does not work on Windows. If you try the above command on Windows, the file wikipedia.html will not be readable by the SingleFileZ extension in the browser (in fact, when I tried this, the file wikipedia.html was not even a valid zip file). I am guessing that the line endings must have messed up the file (because Windows uses \r\n for line endings, whereas *nix uses \n).

The page also says the following:

Run and mount a volume to get the saved file in the current directory

Save one page

docker run -v %cd%:/usr/src/app/out singlefile "https://www.wikipedia.org" wikipedia.html (Windows)

docker run -v $(pwd):/usr/src/app/out singlefile "https://www.wikipedia.org" wikipedia.html (Linux/UNIX)

Save one or multiple pages by using the filename template (see --filename-template option)

docker run -v %cd%:/usr/src/app/out singlefile "https://www.wikipedia.org" --dump-content=false (Windows)

docker run -v $(pwd):/usr/src/app/out singlefile "https://www.wikipedia.org" --dump-content=false (Linux/UNIX)

Each of the above 4 commands use singlefile as the docker image name, when it should instead be singlefilez.

Many thanks!

andrewdbate avatar Oct 11 '21 21:10 andrewdbate

Thank you, I fixed the typos.

However, I was not able to reproduce the issue related to invalid zip files on Windows. When I run the command docker run singlefilez "https://www.wikipedia.org" > out.html on the CLI of Windows 10 (pro), the resulting file is a valid zip and can be opened in Firefox.

gildas-lormeau avatar Oct 11 '21 22:10 gildas-lormeau

I've just double checked on Windows 10 Pro and it works with command prompt but is does not work with PowerShell.

So running docker run singlefilez "https://www.wikipedia.org" > out.html from Command Prompt (cmd.exe) produces a valid file out.html.

However, running docker run singlefilez "https://www.wikipedia.org" > out.html from PowerShell produces a file out.html which is not even a valid zip file.

andrewdbate avatar Oct 11 '21 22:10 andrewdbate

Thank you for the clarification. I'll add a note that it must be run from cmd.exe. I don't know (yet) how to fix this issue in PowerShell.

gildas-lormeau avatar Oct 11 '21 23:10 gildas-lormeau

That seems a little bit complicated with PowerShell, see https://stackoverflow.com/questions/46947168/how-to-get-original-binary-data-from-external-command-output-in-powershell

gildas-lormeau avatar Oct 11 '21 23:10 gildas-lormeau