Python Forum
Subprocess command prompt (Windows)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subprocess command prompt (Windows)
#1
Hello,
I'm making a little program that runs a cmd command on Windows. That command needs a password and a verification of the password from the user to be typed it in the terminal. What I want to do is to send the password myself from the program to the terminal. The program looks something like this:

from subprocess import *
p = Popen("Command that does something and asks  for a password", stdin=PIPE, stdout=PIPE, shell=True)
I have tried different solutions but none of them have worked. I've tried this:

p.communicate(b"secret password\n") #I have tried with and without the \n
And also this:

p.stdin.write("secret password")
I don't get any error message, but the terminal still asks me for password.
Reply


Messages In This Thread
Subprocess command prompt (Windows) - by arnaur - Sep-03-2018, 08:51 AM
RE: Subprocess command prompt (Windows) - by arnaur - Sep-03-2018, 09:43 AM
RE: Subprocess command prompt (Windows) - by arnaur - Sep-03-2018, 10:58 AM
RE: Subprocess command prompt (Windows) - by arnaur - Sep-04-2018, 10:34 AM
RE: Subprocess command prompt (Windows) - by arnaur - Sep-06-2018, 07:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  'pip' not recogmnized in windows prompt MaartenRo 1 449 Dec-21-2023, 09:05 AM
Last Post: menator01
  What is the difference between Command Prompt and Sublimes yaoyao22 1 673 Jul-09-2023, 02:56 PM
Last Post: snippsat
  Using subprocess to execute complex command with many arguments medatib531 5 1,961 Apr-27-2023, 02:23 PM
Last Post: medatib531
  [SOLVED] [Windows] Right way to prompt for directory? Winfried 4 2,106 Jan-17-2023, 09:28 PM
Last Post: markoberk
  Open windows cmd prompt and run cmds with python Extra 3 1,499 Jul-14-2022, 06:07 AM
Last Post: Gribouillis
  Facing Problem while opening a file through command prompt vlearner 4 1,973 Jan-30-2022, 08:10 AM
Last Post: snippsat
  use subprocess on linux\pi wwith a "grep " command korenron 2 8,211 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE
  disable subprocess.popen prompt echo paul18fr 1 2,049 Feb-04-2021, 02:50 AM
Last Post: Larz60+
  Noob warning: trying to use pip to install pytest and pep8 in Command Prompt adifrank 4 5,411 Dec-20-2020, 04:23 AM
Last Post: adifrank
  Running Python in Command Prompt Anwar 3 3,135 Nov-15-2020, 03:15 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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