I'm a newbie and I'm in way over my head with a pressing real world problem I need to solve with python.....one that isn't waiting for me to learn all I need to learn about programming.
I have 3 questions aimed at exploring what I need to know concerning this one area. For the purposes of keeping my explanation of what I want to do simple, let's say that for some reason beyond our grasp, I want my program to su to root. So far, by looking at the docs, I am thinking I can make this system call by saying:
import os
cmd = 'su'
os.system(cmd)
Now, I expect bash is going to reply with a request for information from my script asking for-
Password:
How do I capture that request of "Password:" into a variable so that my program can scan the contents of the variable in order figure out what the system request is?
(In my search for info, I keep getting referred to popen.os to solve this problem, but I can't make head nor tails of reading through it. There is too much I don't understand, I guess.)
And then, once I know what I need to provide to the system, what is the python statement that lets me hand the system back my root password ?
And last, how do I make sure my program waits until the system call, however long it takes to complete, has completed before my program moves on to something new?
|
|
July 4th, 2008 10:15 AM
# 2
|
Re: Capturing a system call REQUEST and then REPLYING
If its a specific problem related to login
try using paramiko you can login using pre-entered passwords
Not the answer you were looking for? Post your question . . .
182,196 Experts ready to help you find a solution.
Sign up for a free account, or
Login (if you're already a member).