Capturing a system call REQUEST and then REPLYING

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • earthdirt
    New Member
    • Mar 2008
    • 3

    Capturing a system call REQUEST and then REPLYING

    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?
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    #2
    If its a specific problem related to login
    try using paramiko you can login using pre-entered passwords

    Comment

    Working...