Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl use Expect; if ($#ARGV != 1) { die "Usage: rexec remote_host command\n"; } $remote_host = $ARGV[0]; $command = $ARGV[1]; $gateway = "abc123"; $remote = Expect->spawn("rlogin $gateway"); $remote->expect(5, "$gateway%") || die "No shell prompt on $gateway\n" +; $sss = "def456"; print $remote "telnet $sss\r"; $remote->expect(5, "login: ") || die "No login prompt on $sss\n"; print $remote "foo\r"; $remote->expect(5, "word:") || die "No password prompt on $sss\n"; print $remote "bar\r"; $remote->expect(5, "\$ ") || die "No shell prompt on $sss\n"; print $remote "rlogin $remote_host\r"; $remote->expect(20, "\$") || die "No shell prompt on $remote_host\n"; print $remote "$command\r"; $remote->hard_close();
Edit Masem - Code tags
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem with Expect
by blakem (Monsignor) on Nov 08, 2001 at 23:43 UTC | |
Re: Problem with Expect
by clemburg (Curate) on Nov 09, 2001 at 14:34 UTC |