Connecting Tech Pros Worldwide Help | Site Map

how to add the user to one unix group using perl

Newbie
 
Join Date: Jul 2008
Posts: 7
#1: Nov 12 '08
Hi

I just wanted to know is there any way in the perl to add a unix user to unix group.
e.g.
I linux we have command to do so,
Expand|Select|Wrap|Line Numbers
  1. usermod -a -G <group> <user>
I have found a CPAN perl module Linux:usermod to do so,Is there any other way except this module ?

Regards,
Ritusriv
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 400
#2: Nov 12 '08

re: how to add the user to one unix group using perl


Alternatively, you can make use of system() command or backticks in Perl, to execute the same linux command.
Newbie
 
Join Date: Jul 2008
Posts: 7
#3: Nov 13 '08

re: how to add the user to one unix group using perl


Quote:

Originally Posted by nithinpes

Alternatively, you can make use of system() command or backticks in Perl, to execute the same linux command.

Thats true but I just wanted to confirm that Is there any way in Perl to do so..
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 400
#4: Nov 13 '08

re: how to add the user to one unix group using perl


Quote:

Originally Posted by Ritusriv

Thats true but I just wanted to confirm that Is there any way in Perl to do so..

There is no straight forward method of doing it in Perl, as far as I know. You have to make use of certain modules. Other than the one you mentioned, you can have a look at Unix::GroupFile module.

- Nithin
Reply