danday74
danday74

Reputation: 57195

printf in nodejs execSync gives error - the system cannot find the file specified

In node when using ..

var child_process = require('child_process')
child_process.execSync("printf 'a'") // works fine
child_process.execSync("printf '<a>'") // throws the system cannot find the file specified

I get the error .. the system cannot find the file specified.

Anyone got any ideas how to fix this? I need to use printf. All I want to do is print <a>

I am using Windows GIT bash. Node v6.11.3

On the command line .. printf '<a>' works fine but printf \'<a>\' gives the same error.

Upvotes: 0

Views: 474

Answers (1)

robertklep
robertklep

Reputation: 203494

Try swapping quote characters:

child_process.execSync('printf "<a>"')

With the quotes the other way around, the executing shell (which is cmd.exe in Windows, I believe) seems to think that you want to redirect a file called "a" into printf (like printf < a).

Upvotes: 1

Related Questions