Python Forum
How to answer subprocess prompt
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to answer subprocess prompt
#6
(Feb-13-2018, 05:18 PM)wavic Wrote: Post the command, please! What it asks for?

process = Popen(['reaver -i wlan1mon -b my:ap:ma:ca:dr:es'], stdin=PIPE, stdout=PIPE, shell=True)
after this is run the console prompts: "Restore previous session for my:ap:ma:ca:dr:es? [n/Y]


(Feb-13-2018, 05:37 PM)nilamo Wrote:
(Feb-11-2018, 09:49 PM)Monty Wrote: I've tried
process.communicate('Y\n') #TypeError: memoryview: a bytes-like object is required, not 'str'


A bytes-like object can be created by putting a b in front of your string. Have you tried: process.communicate(b'Y\n')?

I did try process.communicate(b'Y\n')
But it doesn't run it. I'm guessing it gets stuck on that line when it prompts to continue, if that is the case then the subprocess line would never get completed. Perhaps I need another script to answer to this prompt?

Perhaps I could work-around this by creating a bash script to run a python file with only that line in the background and in the next line it would communicate to that stuck line. Seems like a stupid idea though, there must be a better way.
Reply


Messages In This Thread
How to answer subprocess prompt - by Monty - Feb-11-2018, 09:49 PM
RE: How to answer subprocess prompt - by wavic - Feb-12-2018, 03:21 AM
RE: How to answer subprocess prompt - by Monty - Feb-12-2018, 03:23 PM
RE: How to answer subprocess prompt - by wavic - Feb-13-2018, 05:18 PM
RE: How to answer subprocess prompt - by nilamo - Feb-13-2018, 05:37 PM
RE: How to answer subprocess prompt - by Monty - Feb-13-2018, 06:07 PM
RE: How to answer subprocess prompt - by wavic - Feb-13-2018, 06:29 PM
RE: How to answer subprocess prompt - by Monty - Feb-13-2018, 07:27 PM
RE: How to answer subprocess prompt - by wavic - Feb-14-2018, 09:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  why don't i get the answer i want CompleteNewb 12 3,693 Sep-04-2021, 03:59 PM
Last Post: CompleteNewb
  disable subprocess.popen prompt echo paul18fr 1 2,136 Feb-04-2021, 02:50 AM
Last Post: Larz60+
  I am getting the wrong answer, and not sure why riskeay 3 2,164 Nov-05-2020, 08:24 PM
Last Post: deanhystad
  Make the answer of input int and str enderfran2006 2 2,111 Oct-12-2020, 09:44 AM
Last Post: DeaD_EyE
  Keeps looping even after correct answer mcesmcsc 2 2,037 Dec-12-2019, 04:27 PM
Last Post: mcesmcsc
  I'm getting a wrong answer don't know where the bug is 357mag 4 2,945 Jul-07-2019, 11:21 PM
Last Post: DeaD_EyE
  Subprocess command prompt (Windows) arnaur 6 10,702 Sep-06-2018, 07:22 AM
Last Post: arnaur

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020