LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Perl and using commands within it (https://www.linuxquestions.org/questions/linux-newbie-8/perl-and-using-commands-within-it-916962/)

ochieman2000 12-03-2011 04:38 PM

Perl and using commands within it
 
Hey all,

I have a perl script I am creating. Simple enough, just adds a user and assigned group and permissions.

I keep getting an error when using the -G in adduser

this is my code so far. Also any ideas on how to end the program when done. I was playing with some until conditionals and if else but nothing that I have mastered.

Thanks

Code:

#!/usr/bin/perl
#user add script

print "Welcome to AddUser Script\n\n";
print "To end this program, please enter end as the username\n\n";
print "User Name:";
$userinput =  <STDIN>;
chomp ($userinput);
useradd -G emails $userinput;


corp769 12-03-2011 06:31 PM

Quote:

I keep getting an error when using the -G in adduser
Well what kind of error are you getting? Just saying "an error" could mean many things. Also, are you running that as root?

ochieman2000 12-03-2011 06:52 PM

Can't locate object method "G" via package "emails" (perhaps you forgot to load "emails"?) at adduser.perl line 9, <STDIN> line 1.

Chirel 12-03-2011 06:53 PM

Hi,

replace

Quote:

useradd -G emails $userinput;
by

Quote:

system("useradd -G emails $userinput");
good luck to finish this work.

ochieman2000 12-03-2011 08:43 PM

Quote:

Originally Posted by Chirel (Post 4541305)
Hi,

replace



by



good luck to finish this work.

Wonderful help, Thank you


All times are GMT -5. The time now is 11:40 AM.