HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- PERL's chown
Operating System - HP-UX
1835243
Members
2601
Online
110078
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2002 02:39 AM
05-30-2002 02:39 AM
PERL's chown
HI,
I've inserted a PERL script which is suppose to chown the ownership of files/directories, also links.
The script works ok for ordinary files and directories, but it just map the old uid to the new uid.
Could someone help me in debugging the script?
Thanks.
I've inserted a PERL script which is suppose to chown the ownership of files/directories, also links.
The script works ok for ordinary files and directories, but it just map the old uid to the new uid.
Could someone help me in debugging the script?
Thanks.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2002 02:54 AM
05-30-2002 02:54 AM
Re: PERL's chown
Hi
Look at man chown
You need -h for links
Steve Steel
Look at man chown
You need -h for links
Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2002 05:50 AM
05-30-2002 05:50 AM
Re: PERL's chown
%OldNew = qw ( #maps old user id to new user id
17190 0
);
is (one of your) your problem(s) :)
read again what qw() does. You've just created a hash that looks like
%OldNew = (
"#maps" => "old",
"user" => "id",
"to" => "new",
"user" => "id",
"17190" => 0,
);
probably not what you expected.
Now start adding
use warnings;
use strict;
and see what happens
17190 0
);
is (one of your) your problem(s) :)
read again what qw() does. You've just created a hash that looks like
%OldNew = (
"#maps" => "old",
"user" => "id",
"to" => "new",
"user" => "id",
"17190" => 0,
);
probably not what you expected.
Now start adding
use warnings;
use strict;
and see what happens
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2002 06:01 AM
05-30-2002 06:01 AM
Re: PERL's chown
and BTW, you should take a look at the following perl functions
- stat
- lstat
- readlink
- unlink
- symlink
HP-UX inhibits changing the ownership of a symbolic link from the OS points of view (Steve already pointed you to the -h option of the chown command itself). If you have write permission to the directory, you can remove the link and recreate it (using symlink) as the new user. The symlink then gets the new user id. You can also achieve your goal using 'system "chown -h $newuser $file"'. Don't parse 'ls -ld' output, use stat/lstat/readlink instead, or - even better - the abs_path () function from the Cwd module, which will also 'do the right thing' if the symlink points to a symlink points to a symlink ...
NAME
Cwd - get pathname of current working directory
SYNOPSIS
use Cwd;
my $dir = getcwd;
use Cwd 'abs_path';
my $abs_path = abs_path($file);
DESCRIPTION
This module provides functions for determining the pathname of the
current working directory. It is recommended that getcwd (or another
*cwd() function) be used in all code to ensure portability.
- stat
- lstat
- readlink
- unlink
- symlink
HP-UX inhibits changing the ownership of a symbolic link from the OS points of view (Steve already pointed you to the -h option of the chown command itself). If you have write permission to the directory, you can remove the link and recreate it (using symlink) as the new user. The symlink then gets the new user id. You can also achieve your goal using 'system "chown -h $newuser $file"'. Don't parse 'ls -ld' output, use stat/lstat/readlink instead, or - even better - the abs_path () function from the Cwd module, which will also 'do the right thing' if the symlink points to a symlink points to a symlink ...
NAME
Cwd - get pathname of current working directory
SYNOPSIS
use Cwd;
my $dir = getcwd;
use Cwd 'abs_path';
my $abs_path = abs_path($file);
DESCRIPTION
This module provides functions for determining the pathname of the
current working directory. It is recommended that getcwd (or another
*cwd() function) be used in all code to ensure portability.
Enjoy, Have FUN! H.Merijn
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP