0

I'm running a python script that prints out commands on the terminal (kali linux) to ultimately disconnect my own device from my wifi after x amount of minutes/seconds etc. I can get the commands part down but an issue I'm having is stopping the commands that are running and you have to press a hotkey or a certain keyboard shortcut to exit the search or whatever. I tried keyboard.press() with from pynput.keyboard import Key but that doesn't work. Is there any way to halt the ongoing command so that the code can execute the rest of the remaining code? I'll just post what I have:

 import subprocess
import time
from pynput.keyboard import Key

command1= "ifconfig"
command3 = "airodump-ng wlan0"
time.sleep(10)
subprocess.call(command1, shell=True)
subprocess.call(command3, shell=True)

keyboard.press(Key.ctrl)
keyboard.press('c')

1 Answer 1

0

hope this will help

https://stackoverflow.com/questions/4789837/how-to-terminate-a-python-subprocess-launched-with-shell-true

this is to terminate an on going sub-process in python

1
  • I tried most of the examples but it only stops it for a split second and then it goes back to running again
    – sidereal
    Commented Jun 8, 2021 at 0:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .