I'm trying to run a shell file on python:
mongod --config /opt/mongodb/mongod.conf
and call it on python:
subprocess.call(['bash', 'run.sh'])
but it says mongod : not found.
When I run it in the terminal it works.
How can I fix this?
You don't need to use bash. Just run it as a normal script as you do in terminal:
import subprocess
subprocess.call(['./run.sh'])
Also it seems that mongod is not in your system environment path so you need to add absolute path of mongod to your run.sh:
#!/bin/bash
/opt/mongodb-linux-x86_64-ubuntu1404-3.0.6/bin/mongod --config /opt/mongodb/mongod.conf
run.sh? Try to use subprocess.call(['sh', '<abs path to your run.sh>']).mongod is not in your python env. Try to edit your run.sh and use the absolute path of mongod you can find it with whereis mongod.try :
import os
os.system('bash run.sh')
update command to :
#!/bin/sh
/usr/bin/mongod --quiet --config /opt/mongodb/mongod.conf