At 01:14 PM 6/11/01 -0700, Paul wrote:
> > #!/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.

Check the man page for your passwd, it might have an entry like this:

        --stdin
               This option is used to indicate that passwd  should
               read  the  new  password from standard input, which
               can be a pipe.

There again, when I try it, I get a message that

$ passwd --stdin
Only root can do that

But maybe you *are* root...

Otherwise, you're going to need something like Expect.pm.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com

Reply via email to