Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11434
| Date | 2011-08-15 03:58 +0200 |
|---|---|
| From | Michael Poeltl <michael.poeltl@univie.ac.at> |
| Subject | Re: Commands for changing ownership of a file |
| References | <25d3fa2d-15d9-4b85-8f97-e3fa7ccd7b99@q5g2000yqj.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2295.1313373925.1164.python-list@python.org> (permalink) |
in python-3.2.1 I'm using os.system() again, from time to time
maybe that's the one you were looking for?
>>> os.system('chown user:group /tmp/f')
0
>>> os.system('ls -l /tmp/f')
-rw-r--r-- 1 user group 0 Aug 15 03:52 /tmp/f
and besides os.chown() (where you ned the uid and gid), you could also use subprocess.call() or subprocess.Popen()
regards
Michael
* Jason Hsu <jhsu802701@gmail.com> [2011-08-15 01:15]:
> I have a script that I execute as root, but I need to change the
> ownership of the files created in the script to that of my username.
> In GNU Bash, the command is something like "chown myusername:users".
> What's the equivalent Python command? I know that there is a command
> that uses numbers for the username and group, but is there a command
> that would allow me to use "myusername" and "users" instead of numbers?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Michael Poeltl
Computational Materials Physics voice: +43-1-4277-51409
Univ. Wien, Sensengasse 8/12 fax: +43-1-4277-9514 (or 9513)
A-1090 Wien, AUSTRIA cmp.mpi.univie.ac.at
--------------------------------------------------------------------------------
slackware-12.2/ubuntu-10.10 | vim-7.3 | python-3.2.1 | mutt-1.5.18 | elinks-0.12
--------------------------------------------------------------------------------
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Commands for changing ownership of a file Jason Hsu <jhsu802701@gmail.com> - 2011-08-14 15:56 -0700 Re: Commands for changing ownership of a file Chris Rebert <clp2@rebertia.com> - 2011-08-14 16:37 -0700 Re: Commands for changing ownership of a file Michael Poeltl <michael.poeltl@univie.ac.at> - 2011-08-15 03:58 +0200
csiph-web