On 2004-12-22, Erik Geiger <[EMAIL PROTECTED]> wrote: > Donn Cave schrieb: > >> In article <[EMAIL PROTECTED]>, Erik Geiger <[EMAIL PROTECTED]> >> wrote: > [...] >> > Thats what I've tried, but it did not work. Maybe it's because I want to >> > start something like su -c '/path/to/skript $parameter1 $parameter2' >> > user > >> Unfortunately this particular case kind of dilutes the advantages >> of spawnv. In the common case, parameter1 et al. would be submitted >> directly as the parameter list. I believe it may be clearer to start >> with to think about the spawnv() function - >> os.spawnv(os.P_NOWAIT, path, [cmdname, parameter1, parameter2]) >> >> If one of the parameters is itself another command, then of course >> it has to be rendered as a string >> os.spawnv(os.P_NOWAIT, '/bin/su', ['su', '-c', '%s %s %s' % (cmd, >> parameter1, parameter2)]) >> so you have almost as much work to scan the parameters for shell >> metacharacters as you would have with system(). >> >> Donn Cave, [EMAIL PROTECTED] > OK, thats too high for me ;-) > > Is the %s the variable for the following commands/parameters? If I have > three parameters, I'll need one more %s? Where to write the user for the su > command? > > Well, I've given up ;-) >
Hey, don't give up. There is help. ;-) guess... There is a package called pyNMS (http://sourceforge.net/projects/pynms) That has a module called "proctools", and also one called "sudo". Once you set up sudo correctly, you can do what you want easily. However, be aware that proctools spawns a process with the subprocess stdio connected to _your_ parent process, and does not inherit the stdio of the parent. So, if the subprocess writes a lot of stuff you must read it, or the subprocess will block. However, there is some (perhaps buggy) support for asynchronous operation where those reads happen automatically (on Linux). -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 ===================================================================== -- http://mail.python.org/mailman/listinfo/python-list