python:
for line in sys.stdin:
foo(line)
def foo(name):
return "hello " + name
shell:
welcome_saying = $(echo "Tom" | python welcome.py)
echo "$welcome_saying"
I expected "hello Tom" printed in console, but none.
python:
for line in sys.stdin:
foo(line)
def foo(name):
return "hello " + name
shell:
welcome_saying = $(echo "Tom" | python welcome.py)
echo "$welcome_saying"
I expected "hello Tom" printed in console, but none.
print("hello" + name)
return
returns the value to the calling function, not to the console.
Then you have to write the pipe properly: How do I redirect output to a variable in shell?