How to execute commands in internal zones of solaris using python running from the global zone ?

nntpman68 news1234 at free.fr
Wed Aug 13 03:46:45 EDT 2008


Hishaam wrote:
> How to execute commands in internal zones of solaris using python
> running from the global zone ?
> 
> i tried --
> 1> os.popen("zlogin <zone1>")
> 2> os.popen("zonename")
> 
> the 2nd command executes back into the global zone and not into the
> internal zone
> can anyone help?
> 
> 
> Hishaam


Very probably you didn't want to start two pipes  (two processes on your 
host)



Can you ssh or rsh to zone 1?

Then you want probably something like:

os.popen('echo zonename | ssh <zone1>')


If not you could look at pexpect, though I didn't use it myself so far.
just look at the thread 'SSH utility' to get some examples.
you just had to replace 'ssh' with 'zlogin'

( http://www.noah.org/wiki/Pexpect )



Or you could try popen2, http://docs.python.org/lib/module-popen2.html

Strange thing is though, that popen doesn't seem to exist on my python.
Perhaps it's not a standard library.
No idea. I myself am rather new to python :-(


However if you want to try popen2 read also 17.4.2 'Flow Control Issues'
in order to be sure, that your program doesn't deadlock



[ z1_stdin , z1_stdout ] = os.popen2('ssh <zone1')
z1_stdin.write('zonename\n')
z1_stdout.readline()


bye N






More information about the Python-list mailing list