Re: How to execute linux command in django view
Thank you Preston for the clarification. I am thinking to handle this by just making a python daemon process that will be started as root through shell and this daemon will execute all required shell commands. Daemon will check the actions queue (that can be slq table) and will perform the posted action. And this queue will be filled by django views and vice versa. Anyhow thank you for your response. -- Kashif On Sat, Dec 12, 2009 at 12:32 AM, Preston Holmeswrote: > > > On Dec 11, 10:40 am, Kashif Azeem wrote: > > Thank you Shawn for the reply now i have another problem i.e. on > executing > > some commands like 'vgs' or 'lvs' it didnt executed and the warning > > generated as "Running as a non-root user. Functionality may be > unavailable". > > Any idea how to solve this user issue please? > > Any subprocess started from django will run as the user of the > webserving process. > > mod_wsgi lets you run in daemon mode as a specified user but you would > never run a web process as root. > > "Daemon processes may if required also be run as a distinct user > ensuring that WSGI applications cannot interfere with each other or > access information they shouldn't be able to." > > If you need to run a set number of commands, you'll have to edit your > sudoers file to allow those commands (out of this list's scope) > > Depending on your project, you may want to run django behind a > cherrypy wsgi server that you can run as a user created for the > project. > > -Preston > > > > > -- > > Kashif > > > > > > > > > > > > On Fri, Dec 11, 2009 at 10:07 PM, Shawn Milochik > wrote: > > > The proper way to do that is to use the subprocess module. > > > > >http://docs.python.org/library/subprocess.html > > > > > If you don't want to do much reading, you'll just want to look at > section > > > 18.1.3.1, which gives the way to call a simple shell command the way > you'd > > > do with backticks in Perl. > > > > > However, since you mentioned fdisk, maybe you're actually wanting to > > > interact with the shell command. That's more complicated, but can be > done > > > with the "communicate" method of a subprocess. > > > > > Shawn > > > > > -- > > > > > You received this message because you are subscribed to the Google > Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > > -- > > -Kashif > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- -Kashif -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to execute linux command in django view
On Dec 11, 10:40 am, Kashif Azeemwrote: > Thank you Shawn for the reply now i have another problem i.e. on executing > some commands like 'vgs' or 'lvs' it didnt executed and the warning > generated as "Running as a non-root user. Functionality may be unavailable". > Any idea how to solve this user issue please? Any subprocess started from django will run as the user of the webserving process. mod_wsgi lets you run in daemon mode as a specified user but you would never run a web process as root. "Daemon processes may if required also be run as a distinct user ensuring that WSGI applications cannot interfere with each other or access information they shouldn't be able to." If you need to run a set number of commands, you'll have to edit your sudoers file to allow those commands (out of this list's scope) Depending on your project, you may want to run django behind a cherrypy wsgi server that you can run as a user created for the project. -Preston > > -- > Kashif > > > > > > On Fri, Dec 11, 2009 at 10:07 PM, Shawn Milochik wrote: > > The proper way to do that is to use the subprocess module. > > >http://docs.python.org/library/subprocess.html > > > If you don't want to do much reading, you'll just want to look at section > > 18.1.3.1, which gives the way to call a simple shell command the way you'd > > do with backticks in Perl. > > > However, since you mentioned fdisk, maybe you're actually wanting to > > interact with the shell command. That's more complicated, but can be done > > with the "communicate" method of a subprocess. > > > Shawn > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > groups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > -Kashif -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to execute linux command in django view
Thank you Shawn for the reply now i have another problem i.e. on executing some commands like 'vgs' or 'lvs' it didnt executed and the warning generated as "Running as a non-root user. Functionality may be unavailable". Any idea how to solve this user issue please? -- Kashif On Fri, Dec 11, 2009 at 10:07 PM, Shawn Milochikwrote: > The proper way to do that is to use the subprocess module. > > http://docs.python.org/library/subprocess.html > > If you don't want to do much reading, you'll just want to look at section > 18.1.3.1, which gives the way to call a simple shell command the way you'd > do with backticks in Perl. > > However, since you mentioned fdisk, maybe you're actually wanting to > interact with the shell command. That's more complicated, but can be done > with the "communicate" method of a subprocess. > > Shawn > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- -Kashif -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to execute linux command in django view
The proper way to do that is to use the subprocess module. http://docs.python.org/library/subprocess.html If you don't want to do much reading, you'll just want to look at section 18.1.3.1, which gives the way to call a simple shell command the way you'd do with backticks in Perl. However, since you mentioned fdisk, maybe you're actually wanting to interact with the shell command. That's more complicated, but can be done with the "communicate" method of a subprocess. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to execute linux command in django view
Hello, Can anyone guide me please how to execute Linux command (e.g fdisk) in django view?. I have tried os.system() and commands module of python but the browser goes to busy/loading state and never finishes loading the page for quite a while. How to handle this please? -- Kashif -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.