Skip to content

Instantly share code, notes, and snippets.

@sn1p3r46
Last active December 13, 2018 14:14
Show Gist options
  • Save sn1p3r46/563dc968d1e4ff8b0a1309be3fc0ad4e to your computer and use it in GitHub Desktop.
Save sn1p3r46/563dc968d1e4ff8b0a1309be3fc0ad4e to your computer and use it in GitHub Desktop.
nodejs execFile python script reads the parameter and sends it back through the stdout
const { execFile } = require('child_process');
var js = JSON.stringify({a:"fiore", b:[1,2,3], c:{}, d:[]});
execFile('/tmp/comm.py', [js], { encoding: 'utf8' }, (error, stdout) => {
if (error) {
throw new Error(error);
}
console.log(stdout);
});
#!/usr/bin/env python3
import sys
import json
if __name__=="__main__":
args = sys.argv
print (args)
print (json.loads(args[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment