Python inside bash input error

I pasted python code inside a bash script like this:

#!/bin/bash
echo "You are in Bash"
python <<END
# -*- coding: utf-8 -*-
import os
import sys
import getpass
print "You are in python"
username=raw_input('Bitbucket Username : ')
END
echo "Python ended"

But the problem is that I cannot accept data using raw_inputor inputwhen I embed python in bash. Only Python works fine. What is the problem in my code?

+4
source share
2 answers

Instead of heredoc, simply enter the parameter -cto pass the command:

$ python -c "username = raw_input('Enter name: ')
print 'Hello', username
"
Enter name: Chris
Hello Chris
+3
source

END, bash, . bash Python. python, , , , , EOF Ctrl-D linux, Ctrl-Z . , raw_input() EOFError. , bash. Python , : " . EOF". , . , . , , , , Python ... -. KeyboardInterrupt, .

+2
source

All Articles