Subprocess.CREATE_NEW_CONSOLE

12,620
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.

Share:
12,620
Ben
Author by

Ben

Updated on June 04, 2022

Comments

  • Ben
    Ben almost 2 years

    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