[mod_python] os.system-not working

Graham Dumpleton graham.dumpleton at gmail.com
Sun May 27 07:24:28 EDT 2007

On 27/05/07, deepak battu <deepak.battu at yahoo.co.in> wrote:
> cmd = "nmap -O " + myip + ">
> /usr/local/apache2/htdocs/test/temp/tmp.txt"
>  os.system(cmd)
>  Iran this code in python it is working but when i run this in mod_python
> through apache it is not showing any errors but not giving the correct
> result. plz help me.

Specify an absolute path for the location of 'nmap' because Apache
runs with a quite restrictive PATH and thus the program may not be
able to be found.

Also, Apache runs as a special user which may not have write access to
where you are trying to write the output. Try writing the output file
to /tmp instead.

Finally, I hope your 'myip' value isn't being supplied through a user
editable field in a form because if it has you have just exposed your
box in a way that a remote user could execute arbitrary commands on
your box.


More information about the Mod_python mailing list