I want to use node.js to spawn echo $(python --version)
, if I put this into my terminal it works no problem, I get something like
Python 2.7.12
But if I use the following code:
var spawn = require('child_process').spawn
var child = spawn('echo', ['$(python --version)'])
child.stdout.on('data', function(b){
console.log(b.toString())
})
I just get the string literal echo'ed back to me:
$(python --version)
How to I escape the argument to spawn properly so I get the correct output.
Edit: I specifically want to use spawn, and echo, I would like to know if there is a solution to properly escape the spawn argument...