I have this perl-script to access the server auto, I would like to do the same with unix script.
#!/usr/bin/perl
#script: atutotelnet.pl
$filename1= "log1.txt";
$hostname = "10.57.56.161";
$username = "";
$passwd = "";
$path = "/ / ";
## Conexion y autenticaciòn.
use Net::Telnet ();
$host = new Net::Telnet (Timeout => 10,
Dump_Log => $filename1,
Prompt => '/>/');
$host->open($hostname);
$host->login($username,$passwd);
$host->cmd("cd $path");
@lines = $host->cmd("ls -ltr");
print @lines;
print "\n";
print "Digite el mes";
print "\n";
$mes=<STDIN>;
chop($mes);
@lines1 = $host->cmd("ls -ltr $mes");
print @lines1;
print "\n";
$host->close;
My unix-script is:
#! /bin/bash
(sleep 1;
echo "user";
sleep 1;
echo "password";
sleep 1;
echo "ls -ltr";
sleep 1;
) | telnet 10.57.56.161
Malpa
Thanks for your help.
#!/usr/bin/perl
#script: atutotelnet.pl
$filename1= "log1.txt";
$hostname = "10.57.56.161";
$username = "";
$passwd = "";
$path = "/ / ";
## Conexion y autenticaciòn.
use Net::Telnet ();
$host = new Net::Telnet (Timeout => 10,
Dump_Log => $filename1,
Prompt => '/>/');
$host->open($hostname);
$host->login($username,$passwd);
$host->cmd("cd $path");
@lines = $host->cmd("ls -ltr");
print @lines;
print "\n";
print "Digite el mes";
print "\n";
$mes=<STDIN>;
chop($mes);
@lines1 = $host->cmd("ls -ltr $mes");
print @lines1;
print "\n";
$host->close;
My unix-script is:
#! /bin/bash
(sleep 1;
echo "user";
sleep 1;
echo "password";
sleep 1;
echo "ls -ltr";
sleep 1;
) | telnet 10.57.56.161
Malpa
Thanks for your help.