Python question
Hello,
I'm attempting to modify Xtart to provide a logout and a halt option. Once these are working, I'll add in a loop-until-exit. My idea is that a user can run this from text mode as a pseudo-dm (like gdm); it could even be invoked from the .login file. The file is below; I bolded my changes from the original. I don't know Python. My questions are 1) What is the correct os.execvp syntax for logout? (It complains that it can't find "logout", since logout is in fact an internal bash command.) Is there an alternative I can use? (By logout, I mean logout to the text mode login prompt.) 2) What's the correct os.execvp syntax for shutdown? The syntax below succesfully runs sudo; however, sudo then complains that the user isn't in the sudoers file, which isn't the case. Throw in any other useful mods you come up with. Thanks! Code:
|
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
I dunno for the logout part (maybe exit ?) but for shutdown/reboot try /usr/bin/halt and /usr/bin/reboot :)
|
Hello, I got restart and shutdown working.
However, I still need to get 1) logout working and 2) the loop working (so that when you exit the window manager, the menu is there for you to choose from.) To get halt and reboot working, I just had to break up their arguments into the array as per below. Here's my revised code (bolded are my changed from the original Xtart): Code:
Thanks |
One comment on the code, use elif instead of a bunch of consecutive if clauses.
|
If you knew the pid of the shell you wanted to logout of you could use os.kill()
Here's a link to some python docs that might help you http://docs.python.org/lib/os-process.html You could also check out snakehandlers too! |
All times are GMT -5. The time now is 03:03 PM. |