windows - Python executing commands in the command prompt (taskkill) -


i'm trying use os.system use taskkill command in command prompt. ill gut out part im having trouble with:

os.system('taskkill /s %s /u corp\administrator /p clariion! /pid axauto.exe'%(connection[i])) 

the variable connection[i] ip address of remote computer on same network. can run command straight command prompt locally , directly input ip , know fact work, running command through python in format returns "> unexpected @ time." making silly formatting mistake in line of code? error can seen below: "> unexpected @ time.


edit: i've been told use subprocess module. tried snippet below:

command="taskkill /s %s /u corp\administrator /p clariion! /im axauto.exe"%(connection[i])) subprocess.popen(command, stdout= subprocess.pipe, stdin = subprocess.pipe, stderr=subprocess.pipe) 

it doesnt fail in script doesnt kill process.

try code below:

from subprocess import call  call(['taskkill', '/s', connection[i], '/u', 'corp\administrator', '/py',       'clariion!', '/pid', 'axauto.exe']) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -