On Tue, 12 Jun 2001, Paul wrote:
> --- Daniel Ames <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > 
> > This was brought up before, but the archives didn't really answer my
> > question.
> > 
> > I'm trying to get my script to reset a password for me via the passwd
> > command. Keep in mind, I'm very new, so if this is dumb, try not to
> > laugh:
> > 
> > #!/usr/bin/perl
> > 
> > open(handle, "| passwd joeuser");
> > 
> > print handle "password\n";
> > print handle "password\n";
> > close(handle);
> > 
> > Here's what it spits out:
> > 
> > Changing password for user joeuser
> > New UNIX password: Retype new UNIX password:
> > New UNIX password:
> > New UNIX password:
> > passwd: Conversation error
> > 
> > Then it dies. I know I'm doing this wrong. Any ideas?
> > 
> > Thanks!
> 
> WARNING: *STRICTLY* SPECULATION! =o)
> 
> <guess>
> 
>  maybe passwd is actually reading directly from the terminal, rather
> than just from stdin? You might end up having to fork a process and
> write to `tty`. Hope not, but it's possible.
> 
> </guess>
> 
> List?

i distinctly remember reading something to that effect. the passwd program must
be reading from the controlling terminal /dev/tty. if so the correct way to
implement this entirely in perl would be to set up a pair of pseudo terminals,
fork a process, have the child make the slave pseudo terminal a controlling
terminal and spawn passwd. 

/kk

p.s. i believe that is what expect does, but in a general sort of way

Reply via email to