linux - Python script not waiting for user input when ran from piped bash script -


i building interactive installer using nifty command line:

curl -l http://install.example.com | bash 

the bash script rapidly delegates python script:

# file: install.sh [...] echo "-=- welcome -=-" [...] /usr/bin/env python3 deploy_p3k.py 

and python script prompts user input:

# file: deploy_py3k.py [...] input('====> confirm or enter installation directory [/srv/vhosts/project]: ') [...] input('====> confirm installation [y/n]: ') [...] 

problem: because python script ran bash script being piped curl, when prompt comes up, automatically "skipped" , ends so:

$ curl -l http://install.example.com | bash -=- welcome ! -=- have detected have python3 installed. ====> confirm or enter installation directory [/srv/vhosts/project]: ====> confirm installation [y/n]: installation aborted. 

as can see, script doesn't wait user input, because of pipe ties input curl output. thus, have following problem:

curl [stdout]=>[stdin] bash (which executes python script) = [stdin] of python script [stdout] of curl (which contains @ eof) ! 

how can keep useful , short command line (curl -l http://install.example.com | bash) , still able prompt user input ? should somehow detach stdin of python curl didn't find how it.

thanks !

things have tried:

  • starting python script in subshell: $(/usr/bin/env python3 deploy.py)

you can redirect standard input controlling tty, assuming there one:

/usr/bin/env python3 deploy_p3k.py < /dev/tty 

or

/usr/bin/env python3 deploy_p3k.py <&1 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -