Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7391 > unrolled thread
| Started by | Kurt Smith <kwmsmith@gmail.com> |
|---|---|
| First post | 2011-06-10 13:03 -0500 |
| Last post | 2011-06-11 00:03 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Question About Command line arguments Kurt Smith <kwmsmith@gmail.com> - 2011-06-10 13:03 -0500
Re: Question About Command line arguments Hans Mulder <hansmu@xs4all.nl> - 2011-06-11 00:03 +0200
| From | Kurt Smith <kwmsmith@gmail.com> |
|---|---|
| Date | 2011-06-10 13:03 -0500 |
| Subject | Re: Question About Command line arguments |
| Message-ID | <mailman.91.1307729033.11593.python-list@python.org> |
On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips
<mark@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
$
[toc] | [next] | [standalone]
| From | Hans Mulder <hansmu@xs4all.nl> |
|---|---|
| Date | 2011-06-11 00:03 +0200 |
| Message-ID | <4df2949c$0$49177$e4fe514c@news.xs4all.nl> |
| In reply to | #7391 |
On 10/06/11 20:03:44, Kurt Smith wrote:
> On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips
> <mark@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
> $
$ cat script.py
def main():
print raw_input()
if __name__ == '__main__':
main()
$ echo "fred" | python script.py
fred
$
Hope this helps,
-- HansM
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web