#!/sw/bin/perl
##
##  iLogin -- Interactive Login
##  Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved. 
##

require "$ENV{HOME}/.ilogin";

$tmpfile = "/tmp/tmp.ilogin.$$";

unlink($tmpfile);
open(FP, ">$tmpfile");
print FP "\n";
print FP "Interactive Login (iLogin)\n";
foreach $l (@CFG) {
    $area  = $l->{AREA};
    $hosts = $l->{HOSTS};
    print FP "\n";
    print FP "$area:\n";
    foreach $h (@{$hosts}) {
        $name = $h->{NAME};
        $info = $h->{INFO};
        $type = $h->{TYPE};
        $opt  = $h->{OPT};
        if ($type eq 'ssh') {
            $cmd = "ssh $opt";
        }
        elsif ($type eq 'rlogin') {
            $cmd = "rlogin $opt";
        }
        elsif ($type eq 'expect') {
            $cmd = "expect";
            foreach $c (@{$opt}) {
                $cmd .= " -c '".$c."'";
            }
        }
        print FP sprintf("  %-30s %-30s %10s %%%%S:%s%%%%\n", $name, $info, $type, $cmd);
    }
}
close(FP);
system("iselect -n iLogin -t 'Select Remote Host...' -p5 <$tmpfile"); 
unlink($tmpfile);

##EOF##
