kkbka has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Expect; $user = "root"; $pass = "redhat"; $hostname = "localhost"; $comm = "pwd"; $Expect::Log_Stdout = 1; $match = '# '; $session=Expect->spawn("ssh $user\@$hostname") or die "Error calling external program: $!\n"; $session->log_file( 'output.txt' ); unless($session->expect(1,"password: ")) {}; $session->send("$pass\n"); unless ($session->expect(1,'-re', $match)){print "\nNOT FOUND...\n"}; $session->send("$comm\r"); $session->log_file( 'output.txt' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl expect moudule to interact with Linux terminal
by ww (Archbishop) on Mar 29, 2015 at 18:23 UTC | |
|
Re: perl expect moudule to interact with Linux terminal
by pme (Monsignor) on Mar 30, 2015 at 06:38 UTC | |
by kkbka (Initiate) on Mar 30, 2015 at 17:36 UTC | |
by pme (Monsignor) on Mar 30, 2015 at 21:47 UTC |