Solved

Using Perl and Expect For ID / Password Creation and Maintenance Via Cygwin

Posted on 2006-11-04
5
234 Views
Last Modified: 2010-03-05
Background:  Minimal experience with Perl and none with Expect.  We have 1,000's of users.  150+ Unix servers (Primarily AIX, some Solaris, and a couple of HP-UX).  NIS is not an option and neither is purchasing a commercial product.  The team (40 staff) has to maintain our own ID's across all the servers, plus perform account creations and password maintenance for all internal clients across the same servers.  It's a nightmare and time consuming to say the least.  Trying to build a process that we can run from our desktops through Cygwin.  We must use ssh to connect to each server.  My thought is to use Perl and Expect to automate the process.

Looking For:  Some guidance and code snippets or base script from which to build on.

Pseudo Code:  (All of the below actions (successes, failures, etc.) need to written to a log for audit purposes.  Would create a file containing server names, ID's, UID's for new account creations, unlock ID only flag, old password for existing and new password for new ID's or separate files for each)

Connect to server
   Connection successful?
      Yes, continue.
      No, try next server.
Does ID already exist?
    Yes, is account locked?
       Yes, unlock account.  
          Does client want password reset?
             Yes, reset password.
             No, go to next server.
       No, reset password.
    No, create account and and set new temp password.
Go to next server and repeat process until all servers have been looped thru.

Thanks in advance!!
0
Comment
Question by:ts01206
  • 3
  • 2
5 Comments
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
I've never used expect, and that might make it a little easier.
I've used the Net::Telnet module to log into servers and do some stuff, and it hasn't been to difficult.
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm

There are examples in the documentation.
0
 

Author Comment

by:ts01206
Comment Utility
Thanks Adam for the response.  Unfortunately, I have to use ssh to connect with (that's probably not a bad thing).
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
Towards the bottom, there is an example that uses SSH, as well as one that changes a users password.  (search for "ssh" in the page)

0
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
Comment Utility
0
 

Author Comment

by:ts01206
Comment Utility
Thanks Adam for pointing me to those modules.  Between the two of them, I think I have a good starting point.  I'll likely have further questions, but again, it's a great starting point.  Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Sending email via Perl on Windows 3 123
perl to mysql 5 127
Perl - Mawk 2 69
Perl modules on linux ec2 3 84
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now