I usually do this in Perl:
whatever.pl
while(<>) { #do whatever; }
then cat foo.txt | whatever.pl
cat foo.txt | whatever.pl
Now, I
import sys def main(): for line in sys.stdin: print line if __name__=='__main__': sys.exit(main())