Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:changing': 0.07; 'python': 0.08; 'subject:file': 0.13; 'bash,': 0.16; 'received:131': 0.16; 'root,': 0.16; 'univ.': 0.16; 'wien,': 0.16; '>>>': 0.18; 'jason': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; '(or': 0.23; '(where': 0.23; 'gnu': 0.23; 'command': 0.24; 'aug': 0.24; 'besides': 0.24; "i'm": 0.27; 'url:mailman': 0.28; 'ownership': 0.29; 'script': 0.29; 'equivalent': 0.31; 'michael': 0.31; "what's": 0.33; 'there': 0.33; 'to:addr:python-list': 0.33; 'instead': 0.33; 'url:listinfo': 0.33; 'header:User-Agent:1': 0.34; 'uses': 0.35; 'charset:us-ascii': 0.36; 'url:python': 0.36; 'group,': 0.36; 'created': 0.36; 'for?': 0.37; 'using': 0.37; 'but': 0.37; 'something': 0.37; 'could': 0.38; 'url:org': 0.38; 'subject:: ': 0.39; 'user': 0.39; 'to:addr:python.org': 0.39; 'skip:+ 10': 0.64; 'materials': 0.68; 'username': 0.77; 'voice:': 0.84; 'username.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=univie.ac.at; s=rev2; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date; bh=aVY6JjL1mASawcGHVAterXZt7/ygQ7bQlRnoNMXtAHY=; b=esMIlANh3Sc+zSHCFslt4OK1edbLNggz/tPbKK/+zMJsvI5I5smwrWi9Retoh4a5jdfmKAS8vj9szLyiRI42mFbZQvhkUuqG8ChFSLbjXr/aqaAd9NOiMy/pO3uGom81Lc0wErrZtzTJ8jbtuZWu9QzmAtfZLcvTvomHY2Fek2c=; Date: Mon, 15 Aug 2011 03:58:48 +0200 From: Michael Poeltl To: python-list@python.org Subject: Re: Commands for changing ownership of a file References: <25d3fa2d-15d9-4b85-8f97-e3fa7ccd7b99@q5g2000yqj.googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25d3fa2d-15d9-4b85-8f97-e3fa7ccd7b99@q5g2000yqj.googlegroups.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Univie-Virus-Scan: scanned by ClamAV on justin.univie.ac.at X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313373925 news.xs4all.nl 23951 [2001:888:2000:d::a6]:52173 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11434 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 [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 --------------------------------------------------------------------------------