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?

user3467433
  • 275
  • 1
  • 4
  • 14

1 Answers1

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

Community
  • 1
  • 1
miken32
  • 42,008
  • 16
  • 111
  • 154