is there a way to use javascript to run another file? like lets say i want to run a python file and i want to use javascript to do so like im doing this:
example.js run --> example.py --> example.py(print("Hello World!")
so is this possible or not?
Yes, you could do this with NodeJS and the child_process module.
This would be the JavaScript file:
const { exec } = require("child_process")
exec("python example.py", (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
Here's the example.py:
print("Hello, world!")
Here's that running on my machine: