[Zope] Re: [lazug] Creating Linux DIR
Mike Tran
mtran@shufflemasterrd.com
Tue, 25 Jun 2002 18:27:23 -0600
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.