user1032254
user1032254

Reputation: 451

Run bash scripts from python. MAC OS

I am trying to run scripts for python in MAC OS.

I was unable to run scripts that run Bash.sh scripts, any one here have an idea about how can I run bash.sh From python in Mac OS.

Thanks you for any help :)!

(This is the scripts:

Called: RunScript.sh, and I need to run it from Python Script.)

Upvotes: 0

Views: 3355

Answers (2)

Jim Dennis
Jim Dennis

Reputation: 17500

Presumably you would use the subprocess module.

The questions become:

  • Do you intend to capture output from this script?
  • Do you intend to feed input into it?
  • Does it need to interact with the user via the terminal (that Python is using)?
  • Do need to capture and or deal with error messages or error codes (return values)?

Upvotes: 1

Peter-W
Peter-W

Reputation: 777

Does os.system not work?

import os
os.system("/path/to/script.sh")

Upvotes: 6

Related Questions