Hi, from my login i want to login as a other user ,

S

sumi

Hi, i am very new to python , it is just 2 days i started reading abt
it. I did not understand the above statement. what i want to do is , i
want to login as a super user eg :
$su xyz , and then i need to enter the passwd, i want to do these steps
using python , how can i do it??????????
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

sumi said:
Hi, i am very new to python , it is just 2 days i started reading abt
it. I did not understand the above statement. what i want to do is , i
want to login as a super user eg :
$su xyz , and then i need to enter the passwd, i want to do these steps
using python , how can i do it??????????

You're probably looking for the setuid() and setgid() functions in the
module `os`.

-- Gerhard
 
S

Steven D'Aprano

Hi, i am very new to python , it is just 2 days i started reading abt
it. I did not understand the above statement. what i want to do is , i
want to login as a super user eg :
$su xyz , and then i need to enter the passwd, i want to do these steps
using python , how can i do it??????????

Type ctrl-d to exit Python, then at the command prompt, type su <enter>,
then type your root password.

Then, as root, type python <enter> at the command prompt.
 
G

Ganesan Rajagopal

sumi said:
Hi, i am very new to python , it is just 2 days i started reading abt
it. I did not understand the above statement.

Just read the document at the URL given to you.
what i want to do is , i want to login as a super user eg : $su xyz , and
then i need to enter the passwd, i want to do these steps using python ,
how can i do it??????????

This is a slightly better description of the problem. However it's still not
clear what exactly you want to achieve. Do you need to continue running your
python script as the new user? Or do you want to run other commands as teh
new user? In any case, take a look at pexpect
(http://pexpect.sourceforge.net) and see if it fits your purpose.

Ganesan
 
S

Steve Holden

sumi said:
Hi, i am very new to python , it is just 2 days i started reading abt
it. I did not understand the above statement. what i want to do is , i
want to login as a super user eg :
$su xyz , and then i need to enter the passwd, i want to do these steps
using python , how can i do it??????????
Welcome to Python. The reference to the web page was intended to
indicate that you hadn't made your needs very clear.

Are you aware that "su" creates another process? Also, when it asks for
the password it works *very* hard to ensure that it reads *from the
keyboard* rather than just from standard input.

So, all in all, I'm not sure you really understand what you want to do -
this is not intended as criticism, just that you probably need to step
one pace back, look at things a little larger, and say something that
will give us a bit more context, like:

"My boss tells me we have to be able to run admin commands from inside
the order processing suite. Can anyone tell me how to do this?".

If you *do* understand what you want to do then I'm afraid you still
need to explain yourself more clearly.

regards
Steve
 
J

Jorgen Grahn

Hi, i am very new to python , it is just 2 days i started reading abt
it. I did not understand the above statement.

This one?

http://www.catb.org/~esr/faqs/smart-questions.html

You really should try to understand it.
what i want to do is , i
want to login as a super user eg :
$su xyz , and then i need to enter the passwd, i want to do these steps
using python , how can i do it??????????

What you're probably thinking of is expect-like functionality.
Yes, there's a Python module for doing that, on Unix at least:

"Pexpect - a Pure Python Expect-like module"
http://pexpect.sourceforge.net/

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top