Here's a simple Python program that copies one file to another file. If you are running on a Mac or Linux system it should already be able to run the python program from the command line. If you are running on windows see
this post.
Note that the readline() functions returns an empty string at end-of-file.
copylines.py:
-----8<----------
#!/usr/bin/python
import sys
import os
def main():
if len(sys.argv) != 3:
print ("Usage: copylines.py infile outfile")
return
sourceName = sys.argv[1]
destName = sys.argv[2]
sourceFile = open(sourceName, 'r')
destFile = open(destName, 'w')
line = sourceFile.readline()
while len(line) > 0:
destFile.write (line)
line = sourceFile.readline()
sourceFile.close()
destFile.close()
main()
-----8<----------
--Mark