chown and file ownership

Discussion in 'Perl Misc' started by superfly2, Jul 21, 2004.

  1. superfly2

    superfly2 Guest

    Hello,

    I would like to create a file (using a perl script) that has a particular
    owner and group (say "myowner" and "mygroup"). The script is owned by
    "myowner:mygroup" but the file is currently owned by "base:base". The chown
    command doesn't seem to work in my script (it returns 0 for the number of
    files changed), even though I have added "base" to the myowner and mygroup
    lines in my etc/group file.

    Any help would be appreciated.

    ~Darius
     
    superfly2, Jul 21, 2004
    #1
    1. Advertising

  2. "superfly2" <> writes:

    > I would like to create a file (using a perl script) that has a particular
    > owner and group (say "myowner" and "mygroup"). The script is owned by
    > "myowner:mygroup" but the file is currently owned by "base:base". The chown
    > command doesn't seem to work in my script (it returns 0 for the number of
    > files changed), even though I have added "base" to the myowner and mygroup
    > lines in my etc/group file.


    On most Unix-like OSs only root can use the chown syscall can only be
    used to change owner.

    Note also the "base" is not a number. (perldoc -f chown)

    > Any help would be appreciated.


    Check out the documentation for the Perl chown function and the
    underlying chown syscall on your OS.

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
     
    Brian McCauley, Jul 21, 2004
    #2
    1. Advertising

  3. superfly2

    darius Guest


    > Note also the "base" is not a number. (perldoc -f chown)
    >


    Right, I used the number for "base" as found in my etc/group file, not the
    string "base".
     
    darius, Jul 21, 2004
    #3
  4. superfly2 wrote:
    > Hello,
    >
    > I would like to create a file (using a perl script) that has a
    > particular owner and group (say "myowner" and "mygroup"). The script
    > is owned by "myowner:mygroup" but the file is currently owned by
    > "base:base".


    A wild guess: is the directory configured in such a way that files created
    inside of it have "base:base" (this would be a Unix question, not a Perl
    issue)?

    > The chown command doesn't seem to work in my script (it
    > returns 0 for the number of files changed), even though I have added
    > "base" to the myowner and mygroup lines in my etc/group file.


    On most OSs only root can use chown(), so you would have to run your script
    as root which of course has other implications.

    jue
     
    Jürgen Exner, Jul 22, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GfxGuy

    JNI/Linux/chown

    GfxGuy, May 28, 2005, in forum: Java
    Replies:
    6
    Views:
    2,531
    Ross Bamford
    May 29, 2005
  2. James Colannino

    os.chown()

    James Colannino, Nov 11, 2005, in forum: Python
    Replies:
    3
    Views:
    9,399
    Tim Roberts
    Nov 13, 2005
  3. Carsten Haese

    Re: chown'ing by script

    Carsten Haese, Jan 6, 2010, in forum: Python
    Replies:
    4
    Views:
    298
    Steve Holden
    Jan 6, 2010
  4. Brian Candler
    Replies:
    2
    Views:
    340
    Emiel van de Laar
    Mar 2, 2005
  5. Tim O'Donovan

    chown recursively

    Tim O'Donovan, Jun 9, 2005, in forum: Perl Misc
    Replies:
    18
    Views:
    285
    Michael Zawrotny
    Jun 13, 2005
Loading...

Share This Page