0

So I have an executable UNIX file (which I extracted from a Mac App), and tried to duplicate it. The code is:

var dat = fs.readFileSync("~/FileZilla.app/Contents/MacOS/filezilla",{ flags:'r', encoding:"binary"});
fs.writeFileSync("~/filezilla_copy", dat,{ flags: 'w',  encoding: "binary",});

But what I end up getting is an un-readable document file and not a UNIX EXE file. I can't even run it through terminal, although supposedly I created an exact duplicate of the original file. How do I get this file to be recognized as a UNIX file?

1 Answer 1

1

You need to change the mode of the file to set the execute bit, use fs.chmodSync(). See here for details: How do I use chmod with Node.js

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.