graham.dumpleton at gmail.com
Sun May 27 16:52:50 EDT 2007
On 27/05/07, deepak battu <deepak.battu at yahoo.co.in> wrote: > > hello graham, > i have tried it by using the absolute path like this : > cmd = "/usr/bin/nmap -O " + myip + "> /tmp/tmp.txt" > os.system(cmd) > but no change. Change your command to: cmd = "/usr/bin/nmap -O " + myip + "> /tmp/tmp.txt 2>&1" os.system(cmd) This will ensure that standard error is also capture into output file and you can then maybe see what is going wrong with your command line. Another option is to have: import sys sys.stderr.flush() immediately after os.system call to ensure that any standard error messages are properly flushed through to Apache log. Also suggest you log then actual command being run to the Apache error log before you do it. Ie., cmd = "/usr/bin/nmap -O " + myip + "> /tmp/tmp.txt 2>&1" apache.log_error('RUNNING: ' + cmd) os.system(cmd) Then you can see what what is being run is what you expect. Note, please use reply-all so discussion stays on the mailing list as others may have ideas. Graham > i have votice that this thing worked for another command: > cmd = "/usr/bin/nmap -sP " + myip + "> /tmp/tmp.txt" > os.system(cmd) > > and coming to the myip variable it is giving the correct ip . > plz help me. > > > ----- Original Message ---- > From: Graham Dumpleton <graham.dumpleton at gmail.com> > To: deepak battu <deepak.battu at yahoo.co.in> > Cc: mod_python at modpython.org > Sent: Sunday, 27 May, 2007 4:54:28 PM > Subject: Re: [mod_python] os.system-not working > > 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. > > Graham > > > ________________________________ > Download prohibited? No problem! CHAT from any browser, without download.