The `subprocess` module (in particular, the `check_output` or `call` methods) would be better for this.