In article <canoe_mi+vew6t0ec-kcohouxn7o2a8v6qbbzrzqryvzi+b7...@mail.gmail.com>, Herman <sorsor...@gmail.com> wrote: > I was just trying to do in a shell to quickly monitor a file. Imagine > instead of printing hello, it is "os.system("cat somefile")", etc. > Look like it works if i press an enter after the "import xxx". Thanks.
If you are using a POSIX-compatible shell, the canonical approach for use cases like this is to use a "here document", for example: python - <<EOF import os while True: print('hello') EOF The "-" tells the Python interpreter to read from stdin. The shell supplies the lines between the <<EOF and the matching EOF as stdin. http://en.wikipedia.org/wiki/Here_document -- Ned Deily, n...@acm.org -- http://mail.python.org/mailman/listinfo/python-list