2

Im using this command to compress files in node.js:

var command = '7z a ' + dest + ' ' + orig;
exec( command, function(err, stdout, stderr) { ...});

The problem comes when a file has spaces like 7z a my vacation.zip my vacation.pdf

How could I escape dest and orig?

1
  • 1
    JSON.stringify(dest) should do it Commented Apr 30, 2013 at 11:06

1 Answer 1

3

Try to use spawn:

var spawn = require('child_process').spawn,
    ls    = spawn('ls', ['-l', '/tmp/test with spaces']);

    ls.stdout.on('data', function (data) {
        console.log('stdout: ' + data);
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.