March 13th, 2013, 12:57 AM
About exec and sys.argv
Hi, I'm trying to pass the parameter from PHP to Python script. I've found some example, they used sys.argv. It works fine but my question is how can display every line in my python script? because we actually do execute in only one line.
Here's the code:
$name = 'MynE';
$age = '23';
$tmp = exec("python HelloPython.py $name $age");
The result is got is only "Enter name here: MynE" which is the first line of my python code. So how can I display the next line?
name = raw_input("Enter name here: "+ sys.argv)
age = raw_input("Enter age here: "+ sys.argv)
print "Hello "+name + "You are " +age
It should be
"Enter name here: MynE"
"Enter age here: 23"
"Hello MynE You are 23"
Your answer would be very much appreciated.
March 13th, 2013, 01:55 AM
You're using raw_input(). It's trying to read from the keyboard, but it can't do that so it will just sit and wait.
Don't use raw_input(). Display the prompt and assign the variable.