Please login or register. Welcome to the Studio, guest!

Quick Links:



Llanilek Avatar
Former Elite Mod

Dedicated Studio Member


October 2005
from time to time, your going to want to be really cool and be able to run commands in shell/command prompt from your gui... especially if your lazy like me and cba going into shell every time you need something doing.

to do this we use import subprocess.

Now we are going to use subprocess to call either or command's... hell you can even throw in your custom commands too.

The call function within subprocess takes one argument which we will split into an array to give the correct command.['commandfile', 'command'])

below is an example using syncdb from
import subprocess

def comm_syncdb(request):
      result =['','syncdb'])

you can then call the result varible to print any response from shell.

i know this is a random and small tutorial but it may help someone lol.