Solved

Setting passwd from a ksh script

Posted on 1998-10-21
7
456 Views
Last Modified: 2010-08-05
Is it possible to set a password from within a shell script. I can't seem to find any way to pass the new password to the passwd command. It still will always ask for New Password:.
0
Comment
Question by:johnnyw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
Strange earned 100 total points
ID: 2007516
If your script can be executed by the root or be setuided, you can simply correct master.passwd file without using passwd command. There is an 'adduser' script under FreeBSD that doing many such a things.
0
 

Author Comment

by:johnnyw
ID: 2007517
The script will be run as root. It's running under Sequent Dynix/Ptx 4.4.2. If you can tell me where I can get hold of the script you mention I'll evaluate it. My other alternative is to pass in the encrypted password as a string using the passmgmt command.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007518
UNIX does not allow to pass the password as argument or read it from a file (input redirect) 'cause of security reason.
To do such things you need expect.
0
Industry Leaders: 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!

 

Author Comment

by:johnnyw
ID: 2007519
Cheers. Looking at the expect documentation that will seem to do the trick.

Thanks very much.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007520
So you accepted my comment but a "Strange" answer was graded,
bad luck (for me :-)
0
 

Author Comment

by:johnnyw
ID: 2007521
Sorry I wasn't reading them correctly. I'm new to this site so wasn't paying enough attention.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007522
I'll survive :-)
0

Featured Post

Industry Leaders: 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

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

734 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