By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

Capturing a system call REQUEST and then REPLYING

P: 3
I'm a newbie and I'm in way over my head with a pressing real world problem I need to solve with 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'

Now, I expect bash is going to reply with a request for information from my script asking for-


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?
Jul 4 '08 #1
Share this Question
Share on Google+
1 Reply

P: 107
If its a specific problem related to login
try using paramiko you can login using pre-entered passwords
Jul 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.