conversing with the shell

Chris Liechti cliechti at gmx.net
Mon Nov 19 22:06:03 CET 2001


[posted and mailed]

Michaell Taylor <michaell.taylor at reis.com> wrote in
news:mailman.1006199365.9092.python-list at python.org: 
> I am looking to build a VERY simple load balance app for batch job
> submission on several linux machines.  The basic structure that I have
> in mind is. 
> 
> For M in list_of_machines:
>      fm = 'rsh '+M+' "cat /proc/meminfo"'
>      fcpu = 'rsh '+M+' uptime'
>      freemem = SOMECOMMAND(fm)
>      freecpu = SOMECOMMAND(fcpu)
>      .
>      .
>      parse output of freemem and freecpu
>      .
>      .
>      .
> select machine
> submit job using rsh
> 
> BUT...
> 
> Problem is of course the SOMECOMMAND lines.  I need to query the shell
> for input and then read that input in as a variable.  I could use the
> shell commands to redirect the output to a file and then read the file
> with python, but this seems like a waste.

os.popen commands

you could also make one rsh call out of it:
      fmcpu = 'rsh '+M+' "cat /proc/meminfo;uptime"'

and i wouldn't run rsh on a machine that is connected to the internet. use 
ssh instead (and use at least passwords, best make a new account on these 
machines only for that purpose, RSH authentication is even better).

chris

> FYI, there are only 6-8 machines and fairly low frequency usage, so
> larger load balancing seems like overkill.
> 
> Thanks in advance
> 
> Michaell
> 
>      
> 



-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list