2

I wrote a program (I ran it in the terminal) that goes through a list of terminal commands (Kali Linux).

import subprocess as sub import time sub.call(['airmon-ng', 'start', 'wlan0']) p = sub.call(['airodump-ng','wlan0mon']) time.sleep(10) p.kill() 

The last commmand is airodump-ng wlan0mon. Everything works fine (everything is displayed in the terminal (beacons, essid, etc.).

After a specified time I wish to kill the process (airodump-ng wlan0mon).

I don't want to press Ctrl + C by hand! p.kill() does not work (maybe improper use).

How can I do this? What command should I send through the subprocess module?

2
  • all of this is to automate the task a bit. the program iterates through other commands also. `ifconfig wlan0 down' etc. the code works. i just wish to terminate it. Commented Oct 31, 2015 at 14:37
  • related: How to terminate a python subprocess launched with shell=True Commented Oct 31, 2015 at 17:07

1 Answer 1

0

The subprocess.call method is a high-level API that waits for the process to terminate before returning its exit code. If you need your main process to continue running while the subprocess runs, you need to use the slightly lower-level API: subprocess.Popen, which starts the process in the background.

Using p = sub.Popen(['airodump-ng','wlan0mon']) instead of p = sub.call(['airodump-ng','wlan0mon']) should work.

Sign up to request clarification or add additional context in comments.

1 Comment

now it does. thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.