output from external commands

2005-10-23 Thread James Colannino
Hey everyone. First off, I'm new to the list. I had had a little bit of experience with Perl before discovering Python. The more Python I learn, the more I love it :) I just have a quick question to ask. I know that this is probably a simple question, but I've been googling around, and par

Re: output from external commands

2005-10-23 Thread James Colannino
Mike Meyer wrote: >This is a scripting language feature. Python doesn't have direct >support for it, any more than C++ does. To get that functionality, you >want to use either the os.popen function, or - preferable, but only >available in newer Pythons - the subprocess module. > > Thanks. Jame

Re: output from external commands

2005-10-24 Thread James Colannino
Kent Johnson wrote: >import os >files = os.listdir('.') > Thanks, that's good to know. I still need to use os.popen() for a few things, but I'll be needing filenames also, so when I try to get filenames I'll use the above. James -- My blog: http://www.crazydrclaw.com/ My homepage: http://ja

Regular Expressions and Dividing Strings

2005-11-08 Thread James Colannino
Hey everyone, I have a file containing the following type of data (only an example): root:root What I want to do is take this line and divide it into two separate strings (the ':' character would divide the two strings, so the result of the example above would be "root" and "root.") The names

Re: Regular Expressions and Dividing Strings

2005-11-08 Thread James Colannino
Christoph Haas wrote: >You probably mean: > >a="root:root" >b,c = a.split(":") > >b and c contain both sides of the colon. > > Thanks. That's exactly what I was looking for. james -- My blog: http://www.crazydrclaw.com/ My homepage: http://james.colannino.org/ "A well regulated militia bei

Re: PYTHON LOOSING FOR JAVA???????

2005-11-09 Thread James Colannino
Bill Mill wrote: >+1 QOTW > > My ignorance shows here. What does that mean? :-P James -- My blog: http://www.crazydrclaw.com/ My homepage: http://james.colannino.org/ "If Carpenters made houses the way programmers design programs, the first woodpecker to come along would destroy all of ci

Stopping Execution

2005-11-10 Thread James Colannino
Hey everyone. I remember from my C programming that I can either use the exit() or return() functions to end execution of the main code block. My question is, is there a way for me to do this in Python? I know there has to be, but I can't for the life of me figure out what it is. The reason

Re: Stopping Execution

2005-11-10 Thread James Colannino
Fredrik Lundh wrote: > the usual way: > >sys.exit() # or "raise SystemExit" >[...] > Ah, thank you. I wasn't aware that I'd have to import a module to have that ability. I'm still very new, so I have a lot to get used to :-P James -- My blog: http://www.crazydrclaw.com/ My homepage: htt

Internal Variables

2005-11-11 Thread James Colannino
Hey everyone. I hope I have my terminology right, because I'm not quite sure what to call them. I was just wondering how I can find information in internal variables (for example - and I'm just making this up - __version__ to give me the version of Python.) The only reason I ask is that I'm

os.chown()

2005-11-11 Thread James Colannino
Hey everyone. I tried to use os.chown() in the following manner: os.chown('filename', 'username', 'groupname') I got an error, and when I googled for this function I realized that I must pass the numerical uid and gid. My question is, is there a way for me to change ownership based on the nam

Re: os.chown()

2005-11-11 Thread James Colannino
Mike Meyer wrote: >You want pwd.getpwnam and grp.getgrnam. > > Thanks. Hope my newbie questions haven't gotten on anybody's nerves yet ;) James -- My blog: http://www.crazydrclaw.com/ My homepage: http://james.colannino.org/ "A well regulated militia being necessary to the security of a fr

weird problem with os.chmod

2005-11-11 Thread James Colannino
Ok, so now I have a very interesting problem, this time related to os.chmod. I have the following in a text file: 0600. My script reads that number as a string and converts it to an integer for use with chmod. However, when I do this, instead of the rw-- permissions that I expect, I get

Re: weird problem with os.chmod

2005-11-11 Thread James Colannino
James Colannino wrote: >So then I entered the command print 0600, and saw that the >actual number being output was 384 (why would it output 384?!) > > Ok, so further research revealed that 0600 is actually the octal representation for 384 (which makes sense.) So then, I guess

Re: weird problem with os.chmod

2005-11-11 Thread James Colannino
James Colannino wrote: >Ok, so further research revealed that 0600 is actually the octal >representation for 384 (which makes sense.) So then, I guess my >question would have to be, is there a way for me to make Python aware >that the 0600 I'm passing to int() is octal and no

Detecting problems in a forked process

2005-12-29 Thread James Colannino
Hey everyone. I'm writing a small application in Python that uses os.fork() to create a separate process in which another application is run in the background. The problem is that I need to know whether or not that separate application managed to start and return from within the parent approp