Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2006-11-04
Medium Priority
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!!
Question by:ts01206
  • 3
  • 2
LVL 39

Expert Comment

ID: 17884350
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.

There are examples in the documentation.

Author Comment

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

Expert Comment

ID: 17899338
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)

LVL 39

Accepted Solution

Adam314 earned 1500 total points
ID: 17899477

Author Comment

ID: 17918454
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!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans
Suggested Courses

580 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