Hi All, How do i create a method that will excute a shell script when called? I just wanted to run a local shell script when a user clicks on a button. Appreciate any suggestion, Mike
unrestricted python code is needed (external method, or product). if you don't care about the response from the shell script then using os.system will do the trick.. please validate your input from the web before passing to something like this... import os script_command = 'mkdir /root/path/%s' def execute_my_script(arg): os.system(script_command%arg) if you need to process output try one of the popen modules (see docs on python.org). ZCVS has a nice abstraction over this in its ShellCommandProcessor; hth -k --- "Tran, Mike" <mtran@shufflemaster.com> wrote:
Hi All,
How do i create a method that will excute a shell script when called? I just wanted to run a local shell script when a user clicks on a button.
Appreciate any suggestion,
Mike
__________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
This is a possible bug, so: Zope 2.5.1 Python 2.1.1 I know this isn't the latest python but right now this is just for inhouse development. On with the bug! I noticed I had 16k (yes, thousands) of Acquisition.ImplicitAcquirerWrapper objects. Since this site is hardly used, this seemed odd. After spending a few hours isolating the issue, here's how I can reproduce it. Create a folder in the root, call it "A". Create a dtml document (call it "B") in the folder with this simple body: <html><body> <dtml-var title_or_id> </body></html> Change security on "A". In particular, change "Access contents information" to: acquire: no, anon: no, authenitcated: yes, manager: yes, owner: yes. And save changes. From one browser window, visit "/A/B". In a separate window, open the control panel's debug window. Each time you visit /A/B, the number of Acquisition.ImplicitAcquirerWrapper objects goes up by about three. Repeat until it gets boring. Can anyone else reproduce this? And is it a bug? Charlie Reiman
Charlie, Can you put this issue in the Collector at http://collector.zope.org/Zope? Thanks! - C Charlie Reiman wrote:
This is a possible bug, so: Zope 2.5.1 Python 2.1.1
I know this isn't the latest python but right now this is just for inhouse development. On with the bug!
I noticed I had 16k (yes, thousands) of Acquisition.ImplicitAcquirerWrapper objects. Since this site is hardly used, this seemed odd. After spending a few hours isolating the issue, here's how I can reproduce it.
Create a folder in the root, call it "A". Create a dtml document (call it "B") in the folder with this simple body:
<html><body> <dtml-var title_or_id> </body></html>
Change security on "A". In particular, change "Access contents information" to:
acquire: no, anon: no, authenitcated: yes, manager: yes, owner: yes.
And save changes. From one browser window, visit "/A/B". In a separate window, open the control panel's debug window. Each time you visit /A/B, the number of Acquisition.ImplicitAcquirerWrapper objects goes up by about three. Repeat until it gets boring.
Can anyone else reproduce this? And is it a bug?
Charlie Reiman
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"
On Wed 05 Jun 02 16:14, you wrote:
unrestricted python code is needed (external method, or product). if you don't care about the response from the shell script then using os.system will do the trick.. please validate your input from the web before passing to something like this...
import os script_command = 'mkdir /root/path/%s'
def execute_my_script(arg): os.system(script_command%arg)
if you need to process output try one of the popen modules (see docs on python.org). ZCVS has a nice abstraction over this in its ShellCommandProcessor;
hth
-k
--- "Tran, Mike" <mtran@shufflemaster.com> wrote:
Hi All,
How do i create a method that will excute a shell script when called? I just wanted to run a local shell script when a user clicks on a button.
Appreciate any suggestion,
Mike
Hi all, I've followed Kapil's suggestions above and created an external method called mkdirLinux: #mkdirLinux.py #python script to make linux DIR import os script_command='mkdir /home/test/%s' def mkdirLinux(arg): os.system(script_command%arg) #end of mkdirLinux.py Form Data: <form action="doMkdir" method="post"> <input name="desiredDir" type="text" size="25"> <input type="submit" value="Submit!"> </form> doMkdir method: <dtml-if "portal_membership.getAuthenticatedMember().has_role('createDIR')"> <dtml-call "mkdirLinux(arg=desiredDir)"> <dtml-else> <h3>Permission Denied!</h3> </dtml-if> The "doMkdir" method was called without any error. However, the desired Linux directory did not get created. For testing purposes I've set /home/test/ to chmod 777. My Python is not very good. Does anyone have any ideas what i am doing wrong? I just wanted to allow people with the role "createDIR" to create a linux dir. thanks, Mike
__________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
------------------------ Yahoo! Groups Sponsor ---------------------~--> Tied to your PC? Cut Loose and Stay connected with Yahoo! Mobile http://us.click.yahoo.com/QBCcSD/o1CEAA/sXBHAA/NhFolB/TM ---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to: lazug-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
-- Mike Doanh Tran Shuffle Master Inc.
On Wed, Jun 05, 2002 at 02:58:28PM -0700, Tran, Mike wrote:
How do i create a method that will excute a shell script when called? I just wanted to run a local shell script when a user clicks on a button.
Download ZShell from http://www.librelogiciel.com/software/ and look at is sources, especially the run_exec() method. This will show you how to do. Alternatively you can directly use ZShell from your button. bye, Jerome Alet
You might also consider LocalProc: http://www.zope.org/Members/sspickle/LocalProc It's dumb.. but it works (unix only). It can also do "background" processes, and takes some care to limit what commands can be run, and where. take care, -steve On Thursday, June 6, 2002, at 12:55 AM, Jerome Alet wrote:
On Wed, Jun 05, 2002 at 02:58:28PM -0700, Tran, Mike wrote:
How do i create a method that will excute a shell script when called? I just wanted to run a local shell script when a user clicks on a button.
Download ZShell from http://www.librelogiciel.com/software/ and look at is sources, especially the run_exec() method.
This will show you how to do.
Alternatively you can directly use ZShell from your button.
bye,
Jerome Alet
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I use the following short Python script for testing purposes only (located in the Extensions folder): from os import popen2 def exeshell(self): """ exeshell executes shell command """ (stin,stout) = popen2('script') stin.close() result = stout.read() stout.close() return result The script is called via External Method. hth, Juergen --On Mittwoch, 05. Juni 2002 14:58 -0700 "Tran, Mike" <MTran@shufflemaster.com> wrote:
Hi All,
How do i create a method that will excute a shell script when called? I just wanted to run a local shell script when a user clicks on a button.
Appreciate any suggestion,
Mike
participants (8)
-
Charlie Reiman -
Chris McDonough -
Jerome Alet -
Juergen R. Plasser / Hexagon -
Kapil Thangavelu -
Mike Tran -
Steve Spicklemire -
Tran, Mike