call cmd functions using python

This is the place for queries that don't fit in any of the other categories.

call cmd functions using python

Postby vrkiller » Mon Jul 01, 2013 5:05 pm

I'm looking for a function like c++'s system(""). I know it is slow and bad, but i just need it for testing purposes. I have looked everywhere but i cannot find such a function.
- VrKiller
User avatar
vrkiller
 
Posts: 19
Joined: Fri Jun 28, 2013 10:50 am
Location: Denmark, århus

Re: call cmd functions using python

Postby metulburr » Mon Jul 01, 2013 5:15 pm

there is os.system(),
Code: Select all
>>> import os
>>> os.system('ls')

but the more preferred is subprocess
Code: Select all
>>> import subprocess
>>> subprocess.Popen('ls')
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1512
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: call cmd functions using python

Postby vrkiller » Mon Jul 01, 2013 5:22 pm

Thanks Dude :)
- VrKiller
User avatar
vrkiller
 
Posts: 19
Joined: Fri Jun 28, 2013 10:50 am
Location: Denmark, århus


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot], W3C [Linkcheck] and 3 guests