Question About Command line arguments
Mark Phillips
mark at phillipsmarketing.biz
Fri Jun 10 14:58:42 EDT 2011
On Fri, Jun 10, 2011 at 11:03 AM, Kurt Smith <kwmsmith at gmail.com> wrote:
> On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips
> <mark at phillipsmarketing.biz> wrote:
> > How do I write my script so it picks up argument from the output of
> commands
> > that pipe input into my script?
>
> def main():
> import sys
> print sys.stdin.read()
>
> if __name__ == '__main__':
> main()
>
> $ echo "fred" | python script.py
> fred
> $
>
Kurt,
How does one write a main method to handle both command line args and stdin
args?
Thanks,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110610/aae5a047/attachment-0001.html>
More information about the Python-list
mailing list