Hey everyone. I tried to use os.chown() in the following manner:
os.chown('filen ame', 'username', 'groupname')
I got an error, and when I googled for this function I realized that I
must pass the numerical uid and gid. My question is, is there a way for
me to change ownership based on the name instead of the number? Perhaps
there's a function that will let me lookup the uid from the username,
and the gid from the groupname?
Thanks :)
James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/
"A well regulated militia being necessary to the security of a free
state, THE RIGHT of the people to keep and bear arms SHALL NOT BE
INFRINGED." --United States Constitution, Second Ammendment 3 10065
James Colannino <ja***@colannin o.org> writes: Hey everyone. I tried to use os.chown() in the following manner:
os.chown('filen ame', 'username', 'groupname')
I got an error, and when I googled for this function I realized that I must pass the numerical uid and gid. My question is, is there a way for me to change ownership based on the name instead of the number? Perhaps there's a function that will let me lookup the uid from the username, and the gid from the groupname?
You want pwd.getpwnam and grp.getgrnam.
<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Mike Meyer wrote: You want pwd.getpwnam and grp.getgrnam.
Thanks. Hope my newbie questions haven't gotten on anybody's nerves yet ;)
James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/
"A well regulated militia being necessary to the security of a free
state, THE RIGHT of the people to keep and bear arms SHALL NOT BE
INFRINGED." --United States Constitution, Second Ammendment
James Colannino <ja***@colannin o.org> wrote: Hey everyone. I tried to use os.chown() in the following manner:
os.chown('file name', 'username', 'groupname')
I got an error, and when I googled for this function I realized that I must pass the numerical uid and gid. My question is, is there a way for me to change ownership based on the name instead of the number? Perhaps there's a function that will let me lookup the uid from the username, and the gid from the groupname?
One way is:
os.system( 'chown username:groupn ame filename')
Are you doing this as root? The chown function is usually restricted to
root.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fronq |
last post by:
Hi !
The entire (PHP-) world seems to have the same problem:
Many providers let you upload as one user, lets say "ftpuser", yet then
apache and your script will run as another user e.g. "nobody"
Allways the same trouble:
You would need to chmod your entire website by ftp-client/telnet, to have
things like a php-based file-editor work...
|
by: Sean |
last post by:
What is meant by: "CHOWN the entire casetracker folder to something
that permits the server to write to it, such as apache.apache, or
whatever your Webmaster recommends" - is that 700 or 777...Help
Sean
|
by: LRW |
last post by:
Sorry to crosspost, but I have no idea if this is more a PHP question
of general Linux question.
I have a script that makes changes to image files, montages them into
a jpg, and creates a Web page with that image.
It starts with someone from our graphics dept. who I set up to copy
the image files over to the Linux server with SAMBA.
The files gain the owner/group of "nobody" and permissions of 744.
|
by: Ask Josephsen |
last post by:
Hi NG
If I write the following:
<?php
$file="myfile.JPG";
if ( getmyuid()==fileowner ( $file ) )
{
chgrp ( $file, getmygid() );
chown ( $file, getmyuid() );
|
by: Perttu Pulkkinen |
last post by:
I have a form handler script that creates a new folder for the files sent in
the form. Move_uploaded_file transfers then puts those files there.
But problem is that apache becomes automaticly owner of folder and files, so
later I cannot delete/rename/transfer those files trough winscp. Only load
them if permissions are set ok.
Chown doesn't work, because only superuser can change file's owner. What can
I do? Make 24 h agreement with...
| |
by: Frank McCown |
last post by:
This has probably been answered a million times, but I can't seem to
find the answer.
How can I change the owner of a directory using a Perl command? I
know chown can be used with files, but it doesn't appear to work with
directories.
Thanks in advance,
Frank
|
by: phil campaigne |
last post by:
On Mon, 1 Mar 2004, phil campaigne wrote:
>> Nigel J. Andrews wrote:
>>
>
>
>>> >On Mon, 1 Mar 2004, Phil Campaigne wrote:
>>> >
>>> >
|
by: pankajit09 |
last post by:
Hello,
Howto change the group and owner of a directory .
I am doing this -->
chgrp -R groupname directoryname
but its not working .
|
by: Taorluath |
last post by:
I just made a simple program to create files; I'm trying to get the hang of basic file manipulations.
Whatever file my program makes, the owner of the file is "www-data," so I can't edit it using my regular server user. I can use root to change the ownership to the server user, but I don't want to do that for every file.
That's why I tried to use chown() to give ownership to the server as soon as the file is made, but I get this error:
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |