You read from standard out and write to standard in, right?
#!/usr/bin/env python3 import sys if len(sys.argv) > 1: pipe_in = sys.stdin.read().strip() sys.stdout.write('{} {} \n'.format(pipe_in, ' '.join(sys.argv[1:]))) else: pipe_in = sys.stdin.read().strip() sys.stdout.write('{} \n'.format(pipe_in))You have to be careful with the quotes. If you put double quotes for the strings you get EOL error because of the bash quoting. I've needed some time to get it during this example. I have to test it before to publish
![Confused Confused](https://python-forum.io/images/smilies/confused.png)
victor@jerry:/tmp$ echo hello | ./piped.py world hello world victor@jerry:/tmp$ echo hello | ./piped.py hello victor@jerry:/tmp$ echo hello | ./piped.py | ./piped.py hello victor@jerry:/tmp$ echo hello | ./piped.py beautiful | ./piped.py world hello beautiful world victor@jerry:/tmp$ echo hello | ./piped.py beautiful | ./piped.py beautiful world hello beautiful beautiful world