generating users in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting generating users in perl
# 1  
Old 05-03-2009
generating users in perl

hi, i am trying to write a script to generate a big number of users in perl.. it is actually my second time writting perl .. i used to write shell scripts before. my short script seems not working because "useradd" isn't found by the compiler. if anyone may point out why it would be great. thanks.

Code:
#!/usr/bin/perl

$uName=$ARGV[0];
$uNumStart=$ARGV[1];
$uNumEnd=$ARGV[2];

for($i=$uNumStart; $i<=uNumEnd; $i++)
{
   useradd "$uName.$i" -g 999 -p password;  ## this line useradd not found
   `useradd $uName.$i -g 999 -p password; ##this line no error but users not added
   system(qq{useradd "$uName.$i" -g 999 -p password}); #this line acts the same as the above line
}

three 3 attempts didn't work. anyone has any suggestion would be great.

my next question is, how do i set the password? the -p will only give plain text password in the passwd file or shadow file, which is useless. if anyone could shed some light on this one too then it would be great. however, the first thing i really need to solve is the code above. Thanks

[/code]

for now
# 2  
Old 05-04-2009
add the path of useradd in the argument to system function
here i've got: /usr/sbin/useradd

also check the return status of system call to see if it was successful
# 3  
Old 05-05-2009
generating users in perl

uh.. specifying full path wouldn't do it neither.
# 4  
Old 05-05-2009
Quote:
Originally Posted by k2k
uh.. specifying full path wouldn't do it neither.
Maybe its a permissions problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generating password

Hi, I am new to shell scripting, my requirement is I have to generate password for Users automatically using script and it should send on mail on that particular date using crontab. how to do this? (1 Reply)
Discussion started by: manoj.solaris
1 Replies

2. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

3. Programming

Perl list of users

Hi All i need to write something in perl that on a mac list all the users accounts, and then carries out a copy, ( rsync ) on each one it finds. i was going to use glob, but i want to exclude a certain result here is what i have use Getopt::Std; use POSIX qw(tmpnam); use lib... (1 Reply)
Discussion started by: ab52
1 Replies

4. Red Hat

Showing all users in 'users' and 'top' commands

Hi All, I work in a multi user environment where my school uses Red Hat Linux server. When I issue commands such as "top" or "users", I get to see what others are doing and what kinds of applications they are running (even ps -aux will give such information). "users" will let me know who else is... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. Shell Programming and Scripting

Help with generating a script

I am a biologist who is new to linux and am having difficulty generating a script to do what I want it to do! I have tried basic grep commands, but even that does not give me back the data I want. I have many files that are all currently in .xslx and I'm not sure if they need to be .csv or .txt... (16 Replies)
Discussion started by: kellywilliams
16 Replies

6. Solaris

To restrict the users not to change the passwords for NIS users

Hi All, How to restrict the NIS users not to change their passwords in for NIS users?? and my NIS user is unable to login to at client location what could be the problem for this ? Any body can help me. Thanks in advance. (1 Reply)
Discussion started by: Sharath Kumar
1 Replies

7. Shell Programming and Scripting

need help generating this output

need to check hardware error are zero iostat -en |awk '{ if ( $2 == 0 ) { print " " } else { print " Hardware errors "} } can someone please tell me whats wrong with this ---------- Post updated at 10:19 PM ---------- Previous update was at 10:16 PM ---------- iostat -en ----... (11 Replies)
Discussion started by: arch12
11 Replies

8. Shell Programming and Scripting

Generating Combinations

Hi, I need to generate all combinations upto n-1 level, if the input file looks like say, A B C D . . .... I need to generate all combinations such that first value remains constant and the remaning are combined with all possible ways. Output A AB AC AD ABC (1 Reply)
Discussion started by: zorg4u
1 Replies

9. Shell Programming and Scripting

How can i use system users in perl for login page

Hi, I want to code a script with perl. For this, I need some knowledge. How can i use system user name(with group) and password in my login page? I will be happy if you can help me (2 Replies)
Discussion started by: tahsinaltay
2 Replies

10. AIX

Generating a Subsystem

Hello, I'm trying to generate a subsystem which supports startsrc, stopsrc and refresh I want to specify special arguments in case of stopsrc and refresh for example: startsrc: /bin/testscript start stopsrc: /bin/testscript stop refresh: /bin/testscript restart which should be... (0 Replies)
Discussion started by: funksen
0 Replies
Login or Register to Ask a Question