2

I wanna to run my own non-system external commands in python.

Such as "sudo insteon on 23". Subprocess and os.system are designed for system calls.

Does anybody know how to do it?

Thanks

2
  • 1
    subprocess and os.system can be used to run any external command and typically do not run 'system calls', in fact you don't ever run system calls directly from a command line Commented Apr 9, 2013 at 19:32
  • can you give me example for this? thanks Commented Apr 9, 2013 at 19:50

1 Answer 1

1

You can use subprocess.Popen for this:

import shlex
import subprocess
proc = subprocess.Popen(shlex.split('sudo insteon on 23'))
proc.communicate()
Sign up to request clarification or add additional context in comments.

3 Comments

thanks but it returns "unknow device"
Does sudo insteon on 23 work from the command-line?
Thank you very much. I just forgot to link the usb device. I run it on VirtualBox.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.