I've looked, but I'm sure I am missing this. But I have two files.

I have a python one, and a bash command? (I think thats right? Its a file that I can execute and makes changes but isn't a script?)

But I want to launch it from the python script.

The typical use of this file (we will call it a) would be (from the directory it is in):

./a /System/library/extensions/applehda.kext

note the space there, so I am telling a that is the file it is looking for.

How would I put that in a python script?

I've tried subprocess, os.system, and one other, but I am stuck.


Recommended Answers

All 3 Replies

The one I tried was:


import sys
import os


The simplest way is

import subprocess
subprocess.call("./a /System/library/extensions/applehda.kext", shell=True)

If you want exit status, output and error from your command, you can also try http://www.daniweb.com/software-development/python/code/257449

This is what I've used in the past

import os

os.system('start "" "%s" False' % path)

start executes the file
"" is the name of the console window
%s is the path to the fie
and False was an argument passed to the exe

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.