hi Experts,
I'm new in perl and i don't know whats wrong with my arrays as i'm getting this error:
#!/usr/bin/perl
use Expect;
use strict;
my $user = "root";
my $host = "csadmin21";
my $timeout = 5;
my $command = 'ssh';
my $params = ("$user\@$host");
# Create an array
@home_dir = qw(appia autosys itrs network nyfix support oracle sybase);
# Set a count variable
my $count = 1;
# -- Create the Expect object
my $exp = Expect->spawn($command, $params) or die "cannot spawn ssh command \n";
$exp->expect($timeout, ["csadmin21.PROD ~#"]);
foreach $home_dir(@home_dir) {
$exp->send("cd /opt/home/$home_dir\r");
$exp->expect($timeout, ["csadmin21.PROD $home_dir\r#"]);
$exp->send("mv .k5login .k5login.bak\r");
$exp->send("mv $home_dir .k5login\r");
$count++;
}
$exp->send("exit\r");
$exp->expect($timeout,["Connection to csadmin21 closed."]);
will appreciate much if you can point me to whats wrong with my script.