Why passwd isnt working in shell scripts?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why passwd isnt working in shell scripts?
# 1  
Old 01-31-2003
Why passwd isnt working in shell scripts?

I had to write a script to change my login password, and the script wasnt working fine. When I searched through the previous postings in this forum, I got the solution (using 'expect' tool).

But I would like to know why passwd command isnt working in scripts?
# 2  
Old 01-31-2003
passwd opens /dev/tty for reading. And it will read /dev/tty to obtain a password. Before it reads the terminal, it reconfigures it to turn off echo, so that the password cannot be seen as it is typed. If that reconfiguration fails, passwd will give up. And after it has the password, it turns echo back on. Operations like these simply require a terminal.

If that behavior is acceptable, then the passwd command does indeed work in scripts just fine. The "problem" is that people want the script to be able to supply the password rather than the user of the script. In that case, you need expect.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep -w ip address from a file isnt working need help

I have a file "file1" that contains several ip address , and the "file2" contains several records , each line in file2 contains somewhere the ip address that i am searching in the file1 I use the unix command grep -w for i in `cat file1` do grep -w "$i" file2 >> file3 done ... (9 Replies)
Discussion started by: knijjar
9 Replies

2. Shell Programming and Scripting

Code to remove files when corresponding file doesnt exist isnt working.

I am trying to add some code to the begging of a script so that it will remove all the .transcript files, when their is no coressponding .wav file. But it doesnt work. This is the code I have added: for transcriptfile in `$voicemaildir/*.transcript`; do wavfile=`echo $transcriptfile | cut -d'.'... (2 Replies)
Discussion started by: ghurty
2 Replies

3. Solaris

[Solved] passwd command not working

Hi all, I have got a problem, i have Solaris 8 server, where on running the passwd command, it says permission denied. I have checked /bin/passwd, /etc/passwd, /etc/shadow all have permissions as like one working server. It is happening for root user and all other users. i have tried... (6 Replies)
Discussion started by: varunksharma87
6 Replies

4. Red Hat

how passwd cmd is working

how unix users able to change their password even if they have only read permissions and how backend process will be happening can u explain me which are files need to involved in this process (3 Replies)
Discussion started by: ponmuthu
3 Replies

5. UNIX for Dummies Questions & Answers

Passwd command not working

on Runnning passwd command on HPUX 11.23 I am getting pam_chauthtok: Shared object load failure. Pls help ... (1 Reply)
Discussion started by: ultimatix
1 Replies

6. Shell Programming and Scripting

why isnt cron working?

I am using Ubuntu linux desktop, and I am trying to schedule a sheel script to run every 10minutes. These are the steps I have taken: crontab -e added and saved this line to the file # m h dom mon dow command */1 * * * * /home/enzo/Desktop/dlrecentuse restarted cron: sudo... (5 Replies)
Discussion started by: daydreamer
5 Replies

7. UNIX for Dummies Questions & Answers

editing sqlplus id@passwd in multiple scripts, users and directories

hi all, i was given by my supervisor a task to search for scripts which contain oracle sqlplus i.e "myusername/mypasswd @myDB" in every /home/userfolder, which are, all the scripts made by different user. I've done some find command to search string for sqlplus, but it may up too long to respond.... (8 Replies)
Discussion started by: Helmi
8 Replies

8. Shell Programming and Scripting

Scripts for IDīs free in /etc/passwd

As extracting of the file /etc/passwd the IDīs that have not been used in a range specifies. (2 Replies)
Discussion started by: oscar_acm
2 Replies

9. Shell Programming and Scripting

Move command in the shell isnt executing...

-----------------------------------------------------------------------------Pls find my Q in the bottom--------------------------------------------- #!/bin/ksh #+---------------------------------------------- #| #| Usage: . scripts/run_all.ksh < scripts/run_all.txt #| #| This script... (2 Replies)
Discussion started by: thumsup9
2 Replies

10. UNIX for Dummies Questions & Answers

passwd command not working

Hello All, I am working on Sco unix version 5.0.5. The passwd command has somehow got corrupted and is only displaying the contents of the /etc/passwd file instead of changing the password. I wanted to know if there is any other command through which you can change the password of a user from... (5 Replies)
Discussion started by: rahulrathod
5 Replies
Login or Register to Ask a Question