in reply to Expect module and running "su"

check this out Net::SSH::Expect

If you want to continue using your current method, then just try fixing this:

$exp->spawn($command1, @parameters1) or die "Cannt spawn $command1: $!\n"; $exp->expect($timeout, [qr/assword/i => sub { my $exp1 = shift; $exp->send("root_password\n"); exp_continue; } ] );

Should be:

$exp1->spawn($command1, @parameters1) or die "Cannt spawn $command1: $!\n"; $exp1->expect($timeout, [qr/assword/i => sub { my $exp1 = shift; $exp1->send("root_password\n"); exp_continue; } ] );

As you have defined a new Expect, but you're using the old one?