#!/usr/bin/perl -w

use strict;
use warnings;
use Expect;

my $command = 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no  localhost -p 5555 -l root';
my @parameters = ();

my $exp = new Expect;
$exp->raw_pty(1);
$exp->spawn($command, @parameters)
  or die "Cannot spawn $command: $!\n";

#sleep 3;            # give it time to prepare grub
#$exp->send("\n");   # send some string there:
#sleep 3;            # give it time to prepare grub
#$exp->send("\n");   # send some string there:

$exp->expect(20, ['Password:']);
$exp->send("inttest\n");
sleep 1;
$exp->send("ls -l / >123.txt\n");
sleep 1;
$exp->send("chroot /mnt/gentoo /bin/bash\n");
sleep 1;
$exp->send("env-update && source /etc/profile\n");
sleep 1;
$exp->send("ls -l / >123.txt\n");
sleep 1;
$exp->send("exit\n");
sleep 1;
$exp->send("logout\n");
$exp->soft_close();

