Newbie: issuing shell commands with mod_python
Martin Franklin
mfranklin1 at gatwick.westerngeco.slb.com
Wed Apr 3 07:49:13 EST 2002
On Wednesday 03 Apr 2002 1:32 pm, neil wrote:
> import os
> def main(req):
> child = os.popen("/usr/bin/htpasswd -cb /usr/local/apache/users/myfile
> name1 passwd1")
> data = child.read()
> err = child.close()
> return data
Try this from a python shell:-
[$ python
Python 2.0 (#11, Nov 6 2000, 09:01:06)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> def main(req):
... child = os.popen("/usr/bin/htpasswd -cb BLAHBLAH martin martin1")
... data = child.read()
... err = child.close()
... return data
...
>>> main('foo')
Adding password for user martin
''
Cheers
Martin
More information about the Python-list
mailing list