Last active
December 13, 2018 14:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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