0

This is a sample code snippet which reproduces the issue I'm facing:

import subprocess

ctb_path = "\"C:\\Program Files\\Cold Turkey\\Cold Turkey Blocker.exe\""
exception = input("Enter the exception phrase: ")
subprocess.run(f'{ctb_path} -add Distractions -exception \"*{exception}*\"', check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
choice = input("Enter your choice between 1 & 2: ")

Here, I'm not asked for an input because a newline has been accepted instead and successfully exited the program. What are the possible reasons this may occur? How can it be fixed?

Output of the above code

Refer this for Cold Turkey Blocker's User Guide.

  • 1
    `input()` is to interact with your python code, not a program that you would have run inside it – azro Jun 15 '21 at 17:54
  • See https://stackoverflow.com/questions/19880190/interactive-input-output-using-python – azro Jun 15 '21 at 17:55
  • I just tried it on linux with `['echo', 'test']` as the command, and it worked like it should. Are you putting the command in as a single string like that? That gets an error for me. Can you reproduce the error with a trivial command so that you can show us? – Alex028502 Jun 15 '21 at 17:55
  • I intend to first use subprocess to run a command in cmd. After that's completed, the python program should ask me for input. But it takes a newline as the input, which is returned by the subprocess. That's the issue. I'll add a screenshot showing the output. –  Jun 16 '21 at 01:40
  • Yes @azro that's what I intend to do, interact with my python program AFTER subprocess runs the cmd command. –  Jun 16 '21 at 01:41

0 Answers0