Re: Convert String to Int and Arithmetic

2007-06-12 Thread tereglow
On Jun 12, 10:46 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On 12 Jun., 16:32, tereglow <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I am a complete newbie to Python and am accustomed to coding in PHP/ > > Perl/Shell. I am trying to do the following

Convert String to Int and Arithmetic

2007-06-12 Thread tereglow
Hello, I am a complete newbie to Python and am accustomed to coding in PHP/ Perl/Shell. I am trying to do the following: I have a string: cpuSpeed = 'Speed: 10' What I would like to do is extract the '10' from the string, and divide that by 1000 twice to get the speed of a proc

Using pxssh

2007-03-19 Thread tereglow
Hello, I am trying to convert some Expect/Tcl code into Python by using the Pexpect module. The environment is such that authenticated keys are disabled although SSH is available. I do not have control over this environment, so I'm trying to automate tasks within it via Expect. I noticed that,

Re: Grep Equivalent for Python

2007-03-19 Thread tereglow
On Mar 18, 7:33 pm, [EMAIL PROTECTED] (Aahz) wrote: > In article <[EMAIL PROTECTED]>, > > > > > > tereglow <[EMAIL PROTECTED]> wrote: > >On Mar 15, 1:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > >> tereglow <[EMAIL PROTECTED]> wrot

Re: Grep Equivalent for Python

2007-03-18 Thread tereglow
On Mar 15, 1:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > tereglow <[EMAIL PROTECTED]> wrote: > >... > > > server using the /proc FS. For example, in order to obtain the amount > > of physical memory on the server, I would do the following in shell: > >

Re: Grep Equivalent for Python

2007-03-14 Thread tereglow
Okay, It is now working as follows: memFile = open('/proc/meminfo') for line in memFile.readlines(): if line.startswith("MemTotal"): memStr = line.split() memTotal = memStr[1] memFile.close() print "Memory: " + memTotal + "kB" I'm learning the whole try, f

Re: Grep Equivalent for Python

2007-03-14 Thread tereglow
On Mar 14, 11:57 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Laurent Pointal wrote: > > > Steve Holden a écrit : > >> Regular expressions aren't really needed here. Untested code follows: > > >> for line in open('/proc/meminfo').readlines: > > for line in open(

Grep Equivalent for Python

2007-03-14 Thread tereglow
Hello all, I come from a shell/perl background and have just to learn python. To start with, I'm trying to obtain system information from a Linux server using the /proc FS. For example, in order to obtain the amount of physical memory on the server, I would do the following in shell: grep ^MemT