- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- SMALL GIFT TO UNIX COMMUNITY: Perl script for add ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 06:01 PM
06-20-2007 06:01 PM
SMALL GIFT TO UNIX COMMUNITY: Perl script for add batch users
Over the last 22 years I received lot of help
from known and unknown Unix admins all over
the world.
I also offered my advice whenever I could.
I cannot think of a friendlier community
(some exceptions apply on occasion :)).
Here is one of my attempts to help others.
Several days ago, someone asked me if I
had a script to add Unix acounts in bulk.
I sat down and wrote a Perl script that
works on HP-UX, Linux and Solaris servers.
It provides a summary of steps
required to generate the accounts (easy
to run them anyway).
http://www.circlingcycle.com.au/Unix-sources/add-batch-Unix-accounts.pl.txt
Best wishes from "down-under" (far away Australia)
In Australia, even the sky looks upside
down :)
Amateur Radio VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 07:51 PM
06-20-2007 07:51 PM
Re: SMALL GIFT TO UNIX COMMUNITY: Perl script for add batch users
Thank
Regards,
Fat Scrape
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2007 10:21 AM
06-26-2007 10:21 AM
Re: SMALL GIFT TO UNIX COMMUNITY: Perl script for add batch users
I added support for AIX as well.
Basically, the scritp now grew to the following options:
USAGE: $CMD [-h] [-f accfile] [-p] [-s] [-u startUID] [-x]
Tested operating systems: AIX, HP-UX, Linux, SunOS (Solaris)
-h Print this help message
-f accfile Text file with new login names
One per line, or more-detailed (colon-separated):
newuser:accpasswd:accuid:accgid:GECOS:acchome:accshell
-p User pasword authentication for SSH to remote server
-s Array of remote servers and passwords to execute commands
-u startUID Starting UID number for new accounts
-x Force password change at first login
Examples of entries in the file:
someuser
othacc::500::Jim Smith:/home/newuser:/bin/csh
oraadm:Realpasswd:::::/bin/bash
myacc:::130:::
nwuser5:accpasswd:700:100:Joe Bloggs:/home/nwuser5:/bin/ksh
NOTE: The remote execution is currently 80% ready
I need to think about best method to pass the
commands for remote execution (scp, socket, or...)
I also added support for SSH (password and key exchange).
Because Solaris versio on useradd(1) does
not have "-p" flag, I decided to use Expect module to set password for users:
# Force autoflush right away and after every
# write or print on the currently selected output channel.
$| = 1;
$Expect::Log_Stdout = 0;
# First we have to initialize STDIN in to an expect object.
my $stdin = Expect->exp_init( \*STDIN );
my $stdout = Expect->exp_init( \*STDOUT );
# Here are the prompts
#
my $Prompt = "New Password:";
my $Prompt2 = "Re-enter new Password:";
$Command = "passwd $newuser";
my $sh = Expect->spawn("$Command") or die "ERROR: Spawn failed: $?";
$sh->log_stdout(0); # Log to STDOUT
$sh->expect( 5, '-re', "$Prompt");
print $sh "$Password\n";
$sh->expect( 5, '-re', "$Prompt2");
print $sh "$Password\n";
# Close the command nicely
# No need to be rude and use hard_close()
#
$sh->soft_close();
# Reset autoflush
#
$| = 0;
I am closing the thread now.
Bst wishes,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2007 04:11 PM
09-03-2007 04:11 PM
Re: SMALL GIFT TO UNIX COMMUNITY: Perl script for add batch users
Thanks for sharing. I am looking for the similar tools, but with a slightly different usage. I would like to use it to change user password on remote servers. Can this perl script be used to change password instead of create user?
As for the remote, I try the ssh command line, when I issue passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 10:48 AM
09-04-2007 10:48 AM
Re: SMALL GIFT TO UNIX COMMUNITY: Perl script for add batch users
Yes, slight modification ot the script could be used
just to change passwords.
For HP-UX part, simply remove
lines with useradd(1) statements.
It will then use "usermod.sam -p ..."
to change passwords.
About SSH error. HP-UX setup should
be similar to Linux. I am not sure
what your problem exactly is. It could
be even permissions on home directory
on the remote server. For example, if you use
authorized keys, then SSH by default
uses "StrictModes yes" and SSH sessions
fail if home directory is world-readable...
Cheers,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2008 02:46 AM
06-10-2008 02:46 AM
Re: SMALL GIFT TO UNIX COMMUNITY: Perl script for add batch users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2008 03:18 AM
06-10-2008 03:18 AM
Re: SMALL GIFT TO UNIX COMMUNITY: Perl script for add batch users
thank you very much..
regards,
mustafa