I'm doing a GIT hook in Python 3.5. The python script calls a Bash script that that reads input from the user using read
command.
The bash script by itself works, also when calling directly the python script, but when GIT runs the hook written in Python, it doesn't work as expected because no user input is requested from the user.
Bash script:
#!/usr/bin/env bash
echo -n "Question? [Y/n]: "
read REPLY
GIT Hook (Python script):
#!/usr/bin/env python3
from subprocess import Popen, PIPE
proc = Popen('/path/to/myscript.sh', shell=True, stderr=PIPE, stdout=PIPE)
stdout_raw, stderr_raw= proc.communicate()
When I execute the Python script, Bash's read
does not seem to be waiting for an input, and I only get:
b'\nQuestion? [Y/n]: \n'
How to let the bash script read input when being called from Python?