daikini
daikini

Reputation: 1337

How do I send command with parameters to external cmd application in Python?

I need to execute and send command to external app from python:

.\Ext\PrintfPC /p “C:\Leica\DBX” /l “.\joblist.log”

It is cmd app, Is it possible to hide its console and terminate after all also using only python?

Upvotes: 0

Views: 330

Answers (1)

mac
mac

Reputation: 43061

You are probably looking for the subprocess module. Example for executing the ls -l bash command on a unix system:

subprocess.call(['ls', '-l'])

So, in your case it should probably look something like:

subprocess.call(['.\Ext\PrintfPC', '/p', 'C:\Leica\DBX', '/l', '.\joblist.log'])

Have a look at the linked documentation though, because you can also get the output back from the command line execution by using pipes / Popen objects.

Upvotes: 1

Related Questions