Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Friends,

I have a lot of Perl modules to install and I don't have internet access to CPAN so I can't use perl -MCPAN method of installing. So I am writting shell script to do the work.
#!/bin/sh for i in \ perl_mod1 \ perl_mod2 \ perl_mod3 do echo "do $i ?" read doit if [ $doit = 'y' ] then rm -rf $i tar -xvf ${i}.tar cd $i perl Makefile.PL echo "perl makefile.pl okay?" read key make echo "make okay?" read key make test echo "make test okay?" read key # su root -c "/usr/local/bin/make install" expect -c 'spawn su root -c "/usr/local/bin/make insta +ll" send -- "rootspasswd\r" ' echo "make install okay?" read key cd .. else echo "okay f it" fi done
The problem is that expect doesn't seem to be sending the password to su. I know this really a Perl question but I was hoping some of you nice monks might be able to help me?

Replies are listed 'Best First'.
Re: Using expect to do make install when installing perl mods
by Thelonius (Priest) on Sep 11, 2003 at 19:48 UTC
    I don't know about your specific problem, but you can use CPAN without Internet access. Note this paragraph in the CPAN documentation:
    CPAN.pm works nicely without network too. If you maintain machines that are not networked at all, you should consider working with file: URLs. Of course, you have to collect your modules somewhere first. So you might use CPAN.pm to put together all you need on a networked machine. Then copy the $CPAN::Config->{keep_source_where} (but not $CPAN::Config->{build_dir}) directory on a floppy. This floppy is kind of a personal CPAN. CPAN.pm on the non-networked machines works nicely with this floppy. See also below the paragraph about CD-ROM support.
Re: Using expect to do make install when installing perl mods
by iburrell (Chaplain) on Sep 11, 2003 at 20:59 UTC
    One solution is to use sudo instead of su to change to root to run the install. sudo takes the user's password instead of the root password. It can also be configured to allow specific users. It also has command line options to read the password from stdin and display no prompt.
    echo $password | sudo -S -p '' "make install"
    The password can be stored in the script. Or entered once in the top of script.
Re: Using expect to do make install when installing perl mods
by adrianh (Chancellor) on Sep 13, 2003 at 21:52 UTC

    You can get ExtUtils::MakeMaker to do most of this work for you. Download all of the modules, untar them, and move them all into a single directory.

    Add a Makefile.PL at the root of the directory like this:

    use ExtUtils::MakeMaker; WriteMakefile( NAME => 'MyBundle', VERSION => 0.01, INST_LIB => './blib/lib', INST_ARCHLIB => './blib/arch', );

    Then tar everything up into MyBundle.tgz. You should then be able to do:

    % tar xfvz MyBundle.tgz % cd MyBundle % perl Makefile.PL % make % make test % make install

    to install all of the modules.