Hi all,
I am working on a project that would automate the installation of product o=
n
remote machine(s).
I have a Perl-Expect script ready that would send answers to the questions
asked by the InstallerProgram and thus drive the InstallerProgram
independently without the interaction of user.
Pictiorally:
configurationFile =3D=3D> PerlScript <=3D=3D> InstallerProgram
This PerlScript would read the configurationFile and talk with the
InstallerProgram and provide the answers to the questions the
InstallerProgram asks.
I need this to run this PerlScript from host1 onto host2, host3 ... so that
the product is installed on host2, host3 ...
For this, I am using Net::Telnet to connect to the host then using Expect's
exp_init() to convert this telnet handle to expect's handle. However I coul=
d
not get this working.
Below is the script along with the output.
Script: [Name: telnet.pl]
---------------------------
#!/usr/local/bin/perl
use Expect;
use Net::Telnet;
$prompt =3D '/[\]%>#\$]\s$/i';
$telnetObj =3D new Net::Telnet ( Timeout =3D> 20, Prompt =3D> $prompt);
$telnetObj->open ('host1');
$telnet =3D Expect->exp_init ($telnetObj);
$telnet->log_stdout (1);
$telnet->expect (20, 'login: ');
$telnet->send ("user\r");
$telnet->expect (20, 'Password: ');
$telnet->send ("password\r");
$telnet->expect (20, -re, $prompt);
$telnet->send ("id\r");
$telnet->expect (20, -re, $prompt);
$telnet->send ("ls -ltr\r");
$telnet->hard_close();
## END OF SCRIPT ##
Output:
---------------------------
# ./telnet.pl
=C3=BF=C3=BD%
#
---------------------------
It shows the above output and stops there until timeout occurs.
I also tried this using: (1) IO::Socket::INET (2) IO::Socket::Telnet,
however I could not make it work for me.
I am using -
1. SUN Solaris 10,
2. Perl 5.8.8
3. Expect 1.21
Is there a better way of making this work (using some other module?).
One NOTE: I have contents of the .rhosts file as:
+ +
so that root can directly execute commands using rsh and but cannot login t=
o
the system (using rlogin/ssh)as /etc/default/login has the CONSOLE paramete=
r
enabled (i.e., it is NOT commented out).
Also I dont want to have the passwords stored somewhere.. This would be a
overhead since each time the root password is changed, I need to change the
file storing passwords.
Could any of you please help me on this ?
Regards,
~DeepBlue
--=20
View this message in context: http://www.nabble.com/Please-Help-me-with-Exp=
ect-and-Net%3A%3ATelnet-or-IO%3A%3ASocket%3A%3ATelnet-tp14274995p14274995.h=
tml
Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com.
|