On 10/06/11 20:03:44, Kurt Smith wrote:
On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips
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__':
On 06/10/2011 04:00 PM, Benjamin Kaplan wrote:
On Fri, Jun 10, 2011 at 11:31 AM, Tim Chase
if os.isatty(sys.stdin): #<-- this check
Any reason for that over sys.stdin.isatty()?
my knowledge of os.isatty() existing and my previous lack of
knowledge about sys.stdin.isatty()
:)
-tkc
-
On Fri, Jun 10, 2011 at 11:31 AM, Tim Chase
wrote:
> On 06/10/2011 12:58 PM, Mark Phillips wrote:
>>
>> How do I write my script so it picks up argument from the
>> output of commands that pipe input into my script?
>
> You can check
>
> if os.isatty(sys.stdin): # <-- this check
Any reason for
On Fri, Jun 10, 2011 at 1:33 PM, Dennis wrote:
> On Fri, Jun 10, 2011 at 11:58 AM, Mark Phillips
> fred
>
> ['alice']
> fred
Just realized the if/else will have to be changed slightly if we want
to output both argv and stdin.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jun 10, 2011 at 11:58 AM, Mark Phillips
wrote:
\
>
> Kurt,
>
> How does one write a main method to handle both command line args and stdin
> args?
Here is what I came up with:
The one weird thing, the line from above didn't seem to work so I changed it
if os.isatty(sys.stdin):
to this:
On Jun 10, 2011 10:26 AM, "Mark Phillips"
wrote:
>
> I have a script that processes command line arguments
>
> def main(argv=None):
> syslog.syslog("Sparkler stared processing")
> if argv is None:
> argv = sys.argv
> if len(argv) != 2:
> syslog.syslog(usage())
> els
On 6/10/11 12:58 PM, Mark Phillips wrote:
On Fri, Jun 10, 2011 at 10:41 AM, MRAB mailto:pyt...@mrabarnett.plus.com>> wrote:
On 10/06/2011 18:21, Mark Phillips wrote:
I have a script that processes command line arguments
def main(argv=None):
syslog.syslog("Spark
On Fri, Jun 10, 2011 at 11:03 AM, Kurt Smith wrote:
> On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips
> 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
On 06/10/2011 12:58 PM, Mark Phillips wrote:
How do I write my script so it picks up argument from the
output of commands that pipe input into my script?
You can check
if os.isatty(sys.stdin): # <-- this check
do_stuff_with_the_terminal()
else:
read_options_from_stdin()
-tkc
-
On Fri, Jun 10, 2011 at 11:03 AM, Dennis wrote:
> On Fri, Jun 10, 2011 at 10:58 AM, Mark Phillips
> wrote:
>> On Fri, Jun 10, 2011 at 10:41 AM, MRAB wrote:
>>
>> On 10/06/2011 18:21, Mark Phillips wrote:
>
>>
> How do I write my script so it picks up argument from the output of commands
> that p
On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips
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
fr
On Fri, Jun 10, 2011 at 10:41 AM, MRAB wrote:
> On 10/06/2011 18:21, Mark Phillips wrote:
>
>> I have a script that processes command line arguments
>>
>> def main(argv=None):
>> syslog.syslog("Sparkler stared processing")
>> if argv is None:
>> argv = sys.argv
>> if len(argv)
On 10/06/2011 18:21, Mark Phillips wrote:
I have a script that processes command line arguments
def main(argv=None):
syslog.syslog("Sparkler stared processing")
if argv is None:
argv = sys.argv
if len(argv) != 2:
syslog.syslog(usage())
else:
r = par
I have a script that processes command line arguments
def main(argv=None):
syslog.syslog("Sparkler stared processing")
if argv is None:
argv = sys.argv
if len(argv) != 2:
syslog.syslog(usage())
else:
r = parseMsg(sys.argv[1])
syslog.syslog(r)
ret
14 matches
Mail list logo