[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] [RaQ3] Using chown in Perl scripts



Robert,

<cut>
> Once the script creates the directory, filter, and places the files in
> that directory, I am executing the following in the Perl script:
>
>    mkdir ("$homedir/filter", 0744);
>    chown ($login, $gid, '$homedir/filter');
>    chmod (0600, '$homedir/filter/.forward');
>    chown ($login, $gid, '$homedir/filter/.forward');
>    chmod (0600, '$homedir/filter/.procmailrc');
>    chown ($login, $gid, '$homedir/filter/.procmailrc');
>
> This is what I get:
>
>    drwxr-----   2 root     site#        1024 Jan 20 18:51 filter
>    -rw-rw----   1 root     site#          20 Jan 20 18:51 .forward
>    -rw-rw----   1 root     site#        2788 Jan 20 18:51 .procmailrc
>

  TRUE - you are changing the owner BEFORE the mode which is why the "mode" 
change is not working...  You "no longer" own it, so you can't change it (you 
being whoever the script is running as)...

> As you can see, the permissions nor the ownership are not being set as
> requested. I have tried everying all day, searching for solutions on
> this and other lists as well as Perl docs. I tried using the 'system
> ()' function, altering the order in which it is performed, etc.
> Everything I read regarding Perl tell me that this should work. I am
> now asking to see if it is a Cobalt thing, can anyone tell me if they
> are successfully chowning files in using Perl scripts? If so, how?
>

  CORRECT:  this small cut from my "perl" book:

chown(LIST)
chown LIST
  This function changes the owner (and group) of a list of files.  The first 
two elements of the list MUST be the NUMERICAL uid and gid in that order.....
......

  Last time I looked, admin, admin are not numbers....


> I also tried this simple script (via ssh):
>
> #!/usr/bin/perl
>
> $user = "admin";
> $group = "admin";
> $dir = "/home/software/scripts";
> chmod (0744,$dir);
> chown ($user,$group,$dir);
> print "Done.\n";
>
> This is attempting to do the same thing on the 'scripts' directory,
> which it and it's parent are owned by 'admin' before executing and I'm
> logged in as root. This is what I get (permissions look good, but the
> ownership is the problem):
>

  Yep, this time the "mode" worked because you did it FIRST, but you still 
are using names vice numbers for the "chown" command in perl...
<cut>

Larry Smith
SysAd ECSIS.NET
sysad@xxxxxxxxx