First of all, I want to thank the following people for responding to my
query reguarding how to use Perl to interact with the system adduser
program :
Istvan Csaky Jim Belonis
Brian Weaver Dave Cherkus
Sean Watson Gavin Mercer
Paul E. Rockwell Andrzej Cichocki
Richard L Jackson Jr Hellebo Knut
The original request was as follows :
>
>I am trying to write a Perl script that I can use to feed the appropriate
>answers to the questions asked by "/usr/sbin/adduser". I have tried
>putting the responses in a file and then redirecting the file to the
>adduser process using system(). This works fine until the password
>prompt. The adduser process will not read this line out of the file.
>
> My second attempt is to use pipe() and fork(), however I am not
>getting too far with this as well.
>
The following suggestions were given :
1) Use a different version of the passwd. Several people have
volunteered versions of their own passwd programs. I also looked
at the sample passwd program that is in Larry Wall's Programming PERL
book.
I decided against this method since I need to put this code on
multiple systems and I don't generally like overiding OS level
routines, since they may change in future releases and have an
impact on my code.
2) Use the Chat2.pl libraries to communicate with the process running
the adduser script. Right idea, but I could not get it to work
properly, so this idea was out.
3) The most popular suggestion was to go away from Perl and use
TCL/Expect. Well, I have never worked with either of them before.
I grabbed the source and installed it with no problems at all. I
wrote the expect script and it works great. Having looked at
the expect possibilities, I will start to use it in other areas.
You can find the source at :
expect :
ftp://ftp.cme.nist.gov/pub/expect
TCL :
ftp://ftp.smli.com/pub/tcl
Thanks again for all the suggestions.
Neil :-)
\\\//
(o o)
------------------ooO-(_)-Ooo-----------------------------------------
Neil Movold Phone : +1 809 296-1800
Special Operations Consultant Fax : +1 809 295-7269
( i.e. the guy who has to
make it all work :-) )
Internet (Bermuda) Limited E-mail : nmovold_at_ibl.bm
P.O. Box HM2445
Hamilton, Bermuda
HM JX
Received on Wed Sep 27 1995 - 18:40:37 NZST