Module cat
[hide private]
[frames] | no frames]

Source Code for Module cat

 1  #!/usr/bin/env python 
 2  """ 
 3  Very simple program that mimics the behavour of cat under unix but written in python 
 4  Written by Jerome Kieffer, october 2010  
 5  """ 
 6  import sys, os 
 7   
8 -def stdin3stdout():
9 "Copy stdin to stdout" 10 sys.stdout.write(sys.stdin.read())
11 12 if __name__ == "__main__": 13 if len(sys.argv) >= 2: 14 for filename in sys.argv[1:]: 15 if os.path.isfile(filename): 16 sys.stdout.write(open(filename, "rb").read()) 17 elif filename == "-": 18 stdin3stdout() 19 else: 20 sys.stderr.write("cat: %s: No such file or directory" % filename) 21 else: 22 stdin3stdout() 23