[Zope] calling os.system using external method

sean.upton@uniontrib.com sean.upton@uniontrib.com
Wed, 25 Jun 2003 13:15:04 -0700


Some notes on spawning an external process, assuming you want it to
"detach."
http://aspn.activestate.com/ASPN/Mail/Message/zope-List/1629207

> -----Original Message-----
> From: J Cameron Cooper [mailto:jccooper@jcameroncooper.com]
> Sent: Wednesday, June 25, 2003 1:07 PM
> To: zope@zope.org
> Subject: Re: [Zope] calling os.system using external method
> 
> 
> >
> >
> >I have an External method that uses os.system to execute 
> >a linux command on a local host.  I am trying to pass a file name
> >to the findDocs function (see below) to locate the location 
> (path) of the 
> >wanted file and print it out on a dtml document.  Can 
> someone please show me 
> >how to make this work?
> >
> >Thanks in advanced for any suggestions.   
> >
> >#Python script to find location/path of local file
> >import os
> >unixCommand = 'find /home/uploads/ -name %'
> >def findDocs(arg):
> >  os.system(unixCommand%arg)
> >
> >DTML:
> ><dtml-call "externalMethodName(arg=fileName)">
> >  
> >
> I suspect you'll want to use one of the commands that allows 
> you to get 
> the results of a system call. Without the Python docs in 
> front of me, I 
> think that's 'os.popen' or similar. Maye you can do it with 
> 'os.system', 
> but I don't do it enough to have memorized it.
> 
> Split the results from stdin into elements of a list(by newline, 
> probably), and call it with a list iterator (like dtml-in) to do your 
> rendering. Shouldn't be more that five or six lines.
> 
>           --jcc
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>