How Do You Get Redirected Input?
not your business
not.valid at address.org
Wed Jul 2 15:10:09 EDT 2003
I have a shell tool that accepts arguments on the command line. I would like
to check if the input is being piped in. That is,
$ mytool.py < cmdlst.txt
In this case sys.argv is empty. So I added
pipein = os.read(sys.stdin.fileno(),256)
if (pipein):
input_args = pipein.split()
else:
input_args = sys.argv[1:]
Problem is that if nothing is redirected in, the script waits for a Enter
pressed on the the keyboard. Anyone know a solution to this? Thanx in
advance for any help.
More information about the Python-list
mailing list