a popen command line question

2009-08-30 Thread Joni Lee
Hi all,

I write a small script

status = os.popen('top').readlines()
print status

It calls the command line "top" and will print out the status.
But I have to press the keyboard "q" to quit "top", then the status will be 
printed, otherwise it just stands by with blank.

Question is. Do you know how to give "q" into my python script so that "top" is 
automatically quit immediately or maybe after 1s (for gathering information)

Sorry the question is weird.



  -- 
http://mail.python.org/mailman/listinfo/python-list


a popen question. Please help

2009-08-30 Thread Joni Lee
Hi all,

I write a small script

texts = os.popen('top').readlines()
print texts

It calls the command line "top" and will print out some texts.
But first I have to press the keyboard "q" to quit the subprocess "top", then 
the texts will be printed, otherwise it just stands by with blank.

Question
is. Do you know how to give "q" into my python script so that "top" is
automatically quit immediately or maybe after 1s and print out the texts.

Thank you



  -- 
http://mail.python.org/mailman/listinfo/python-list


Help newbie with how to call a source command

2009-08-13 Thread Joni Lee
Hi all,
 
I'm landing here because I need some help that I couldn't get through it.
Question 1. 
I want to call a source command from python script. It will source 
some variables enviroment for further commands. I tried the following which did 
not work
os.sys('source '+source_text)
call(['source',source_text], shell=True)
commands.getoutput('source '+source_text)
 
Anyone have experiences with this? Because I'm very new to this world so a 
details reply is really appreciated!!! thank you very much
 
Question 2.
I call a shell command from python, this time it runs a script which runs some 
ruby scripts. And the error returns: "ruby: command not found"
 
Thank you again


  -- 
http://mail.python.org/mailman/listinfo/python-list