Ansuman Dash schrieb:

Hello Everybody,

In Python scripting, how can I execute a command (which can be run from spcific directory) and then retrieve the result (after executing the command it give the command is executed successfull or not), so that I can validate it.

Thanks,
AD



import os
import subprocess

os.chdir('/your/directory')
p = subprocess.Popen("ls -l", shell=True, stdout=subprocess.PIPE)
out = p.stdout.read()
print out

- Patrick

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to