from serial import Serial from sys import argv, stdout s = Serial(argv[1], int(argv[2])) while True: x = s.read(1) stdout.write(x) stdout.flush()