Changing Ownership

2002-02-19 Thread slhgkh5

I am working on AIX 4.3 and attempting to change 
ownership of files.  Below is an excerpt from my script 
of the area that is causing the problem.

defined($user = getpwnam $_) or die Bad user name;
defined($group = getgrnam staff) or die Bad group
name;
chdir /home/$_;
chown $user, $group, glob *;

The input $_ is the username either from a file or User 
input inside 
a loop.  The user
has a choice.  When I run the above I get bad username.  
It is like it is trying to lookup the numeric user ID 
for $_ and not 
what $_ actually contains.  If I replace $_
with an actual user name in the getpwnam function it 
works fine.

Any comments or suggestions would be appreciated.

Thanks in Advance.

Grant

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Changing Ownership

2002-02-19 Thread Timothy Johnson


Okay, I have to ask...

Are you chomping your user input before you pass it to the function?
Have you tested what $_ prints out?  (E.g: print \#$_\#;)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 11:56 AM
To: Perl Beg
Subject: Changing Ownership


I am working on AIX 4.3 and attempting to change 
ownership of files.  Below is an excerpt from my script 
of the area that is causing the problem.

defined($user = getpwnam $_) or die Bad user name;
defined($group = getgrnam staff) or die Bad group
name;
chdir /home/$_;
chown $user, $group, glob *;

The input $_ is the username either from a file or User 
input inside 
a loop.  The user
has a choice.  When I run the above I get bad username.  
It is like it is trying to lookup the numeric user ID 
for $_ and not 
what $_ actually contains.  If I replace $_
with an actual user name in the getpwnam function it 
works fine.

Any comments or suggestions would be appreciated.

Thanks in Advance.

Grant

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]