Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subprocess.CREATE_NEW_CONSOLE

I have this Python code.

import subprocess

subprocess.Popen("airmon-ng check kill", creationflags = subprocess.CREATE_NEW_CONSOLE)

Python 2.7.6 on Linux Mint gives me the following error:

    subprocess.Popen("airmon-ng check kill", creationflags = subprocess.CREATE_NEW_CONSOLE)
    AttributeError: 'module' object has no attribute 'CREATE_NEW_CONSOLE'

The same on Windows 8.1 gives me this:

Traceback (most recent call last):
File "C:\Users\Ben\Dropbox\Coding\jam.py", line 10, in <module>
subprocess.Popen("airmon-ng check kill", creationflags = subprocess.CREATE_NEW_CONSOLE)
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
like image 702
Ben Avatar asked Dec 09 '25 06:12

Ben


1 Answers

subprocess.Popen("airmon-ng check kill", shell=True)

Will do what you want, which I presume is to open a shell and execute airmon-ng check kill through Python. I've looked through the subprocess docs and the only thing pointing to CREATE_NEW_CONSOLE states that creationflags is only available in Windows which would explain why it doesn't work in Linux Mint. The docs for CREATE_NEW_CONSOLE also states that

The new process has a new console, instead of inheriting its parent’s console (the default). This flag is always set when Popen is created with shell=True.

So just using shell=True is the best way to do what you want.

like image 83
developius Avatar answered Dec 12 '25 04:12

developius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!