0

I have this code in Python which runs perfectly well. What it does is it deletes files from a list on a filesheet. Now my question is if the cmd returns file not found could not delete how can I make Python aware of it so that I could put in a log the files I haven't deleted? I thought error handling would help but it wasn't an error in part of Python since I was just invoking the cmd through Python. Any ideas are welcome. :)

Example of how I invoke the cmd:

import os
os.system('CLS()')
1
  • How is the Python script invoking it? Commented Sep 6, 2011 at 2:27

2 Answers 2

1

From the docs:

"The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes."

http://docs.python.org/library/subprocess.html

Sign up to request clarification or add additional context in comments.

Comments

0

Here are the codes I was used and work well in Windows environment:

import subprocess
subprocess.call(["cmd"])

It's also available to accept more parameters as list in Python And it also could invoke your *.exe app to execute.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.