[Tutor] python newbie..system call help
dyoo at hkn.eecs.berkeley.edu
Wed Jul 13 06:49:41 CEST 2005
On Tue, 12 Jul 2005, Mike Pindzola wrote:
> I have figured many things out. system works, i just forgot to type
> os.system(). I have been looking into the os module and am finding alot
> of useful stuff. I still need to workout the best way to ask a user for
> a root password, show **** when typed and then pass it to the system...
For the password thing, you may find the getpass module useful:
It'll do that password obscuring stuff for you.
You mentioned earlier, though, that you might want to execute stuff using
su --- have you considered using sudo?
It might eliminate the need to type root passwords all the time, and if
used properly, sudo's can be safer since it can be configured to provide
access to a subset of commands.
> > Aside from that, just so copying of files, making dirs, and changing
> > file permissions.
For the rest of these, it is possible to use utilities in Python's
standard library instead of shelling out. Some of these functions live in
the 'shutil' library:
and others in the 'os' module that you've been looking at earlier. For
example, changing the current working directory can be a matter of calling
the os.chdir() function.
If you have more questions, please feel to bring them to the Tutor group.
Good luck to you!
More information about the Tutor