Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>
> > Assuming the script isn't setuid, this would do no more damage than the
> > user could do directly on the command line.
>
> except that when the user is typing things into the command line, he
> *knows* that he's typing
[EMAIL PROTECTED] wrote:
> Assuming the script isn't setuid, this would do no more damage than the
> user could do directly on the command line.
except that when the user is typing things into the command line, he
*knows* that he's typing things into the command line.
--
http://mail.python.o
Nick Craig-Wood wrote:
>
> What if I entered "; rm -rf * ;" as my pattern?
>
Assuming the script isn't setuid, this would do no more damage than the
user could do directly on the command line. I agree, when dealing with
web applications or setuid programs, direct shell access isn't a good
idea.
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Also, for a wrapper around popen, try commands:
>
>import commands
>
>pattern = raw_input('pattern to search? ')
>print commands.getoutput('grep %s *.txt' % pattern)
What if I entered "; rm -rf * ;" as my pattern?
Don't ever pass user
[EMAIL PROTECTED] wrote:
> Also, for a wrapper around popen, try commands:
>
> import commands
>
> pattern = raw_input('pattern to search? ')
> print commands.getoutput('grep %s *.txt' % pattern)
that's not quite as portable as the other alternatives, though. "grep"
is at least availabl
Fredrik Lundh wrote:
> import os
> for line in os.popen("grep pattern *.txt"):
> print line,
>
> also see os.system and subprocess.
>
> note that if you want to write portable code, you can implement your own
> "grep" using the "re" module:
>
Also, for a wrapper a
Bin Chen wrote:
> I want to do following: get a user input regex, then pass this as a
> parameter to grep, and then get the result from grep.
>
> Any code snip to implement the similar function? I am a python newbie.
import os
for line in os.popen("grep pattern *.txt"):
Hi,
I want to do following: get a user input regex, then pass this as a
parameter to grep, and then get the result from grep.
Any code snip to implement the similar function? I am a python newbie.
Thanks a lot.
Bin
--
http://mail.python.org/mailman/listinfo/python-list