Depending on your server the error could be that the group doesn't exist i.e. 
on unix you would need to add the groups to /etc/group first. 

-----Original Message-----
From: Jyotishmaan Ray [mailto:[EMAIL PROTECTED] 
Sent: 20 August 2008 13:17
To: beginners@perl.org
Subject: What is wrong with this script ??

Dear All,

I have a input file containing all the rolnos of 400 studenst. I have written a 
small perl script to create their home directories in the cluster server. 

everything worked fine except for the reason that, it shows up error message 
indicating that the following messages for example: 

when my input file rr.txt contains the following roll nos.:-


s08-1-5-095
s08-1-5-096
s08-1-5-097

the error messages displayed are :-

[EMAIL PROTECTED] perl]# perl h20.pl
chgrp: invalid group `s08-1-5-095'
chgrp: invalid group `s08-1-5-096'
chgrp: invalid group `s08-1-5-097'

The ls -l listing shows up the following :-


drwx------ 2 s08-1-5-095 root   4096 2008-08-20 17:28 s08-1-5-095
drwx------ 2 s08-1-5-096 root   4096 2008-08-20 17:28 s08-1-5-096
drwx------ 2 s08-1-5-097 root   4096 2008-08-20 17:28 s08-1-5-097


As shown above the group is shown as root, but i want each student to be the 
group itself, for example it should be :

drwx------2 s08-1-5-095         s08-1-5-095     4096 2008-08 17:28    
s08-1-5-095

The perl script is shown below:

Can anyone tell me what changes should I make in the script so as to make the 
group same as owner i.e., the roll no. itself.



#!/usr/local/bin/perl
$file = '/root/perl/rr.txt';
open(PWD, $file);
while(<PWD>)
{
($a)=split(/\s+/,$_);
#system("mkdir /root/perl/$a");
system("chmod 700 /root/perl/$a");
#system("chown   /root/perl/$a  $a");
system("chgrp  $a  /root/perl/$a" );
}
close(PWD);
~               














Thanks,
Jyotishmaan Ray Moderator Of Paradise Groups 
http://yahoogroups.com/group/Spirituality-Paradise Are You Spiritually Aware  
!!! Are You Enjoying Yourself  !!!  See What All You Had Been Missing !!!!
Please Join Immediately By Sending A Blank Mail @ [EMAIL PROTECTED] 
   


      

This e-mail is from the PA Group.  For more information, see www.thepagroup.com.
This e-mail may contain confidential information.  
Only the addressee is permitted to read, copy, distribute or otherwise use this 
email or any attachments.  
If you have received it in error, please contact the sender immediately.  
Any opinion expressed in this e-mail is personal to the sender and may not 
reflect the opinion of the PA Group.
Any e-mail reply to this address may be subject to interception or monitoring 
for operational reasons or for lawful business practices.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to