Created
October 1, 2009 15:34
-
-
Save Woody2143/199047 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SnoopDatabase::File; | |
sub get_url { | |
use Expect; | |
$Expect::Exp_Internal = 0; | |
$Expect::Log_Stdout = 0; | |
$Expect::Multiline_Matching = 1; | |
my ($proxy, $callid, $start_time, $end_time, $ticket) = @_; | |
my $timeout = 600; | |
my $result; | |
my $ssh = new Expect; | |
$ssh->raw_pty(1); | |
my $command = "/usr/bin/ssh -i /var/www/localhost/htdocs/snoop/key/web_rsa woody\@host"; | |
$ssh->spawn($command) | |
or die "Failed to spawn SSH session... $!\n"; | |
$ssh->expect($timeout, | |
[qr/\$ / => sub { my $self = shift; | |
$self->send("~/bin/snoop_files.pl --proxy $proxy --callid $callid --starttime $start_time --endtime $end_time --ticket $ticket\n"); | |
}], | |
["PASSCODE:" => sub { $ssh->soft_close(); | |
die "FAILED: Received PASSCODE prompt."; | |
}], | |
["Please Enter the Next Code from Your Token:" => sub { $ssh->soft_close(); | |
die "FAILED: Received NEXT PASSCODE prompt."; | |
}], | |
["RADIUS DOWN, Unix password:" => sub { $ssh->soft_close(); | |
die "FAILED: Received PASSWORD prompt."; | |
}], | |
["continue connecting" => sub { $ssh->send("yes\n"); | |
exp_continue; | |
}], | |
[timeout => sub { $ssh->soft_close(); | |
die "FAILED: Process to pull snoop file timed out."; | |
}], | |
) or die "FAILED: to run snoop_files.pl $!.\n"; | |
$ssh->expect($timeout, | |
["FAILED: " => sub { my $self = shift; | |
$result = $self->after(); | |
exp_continue; | |
}], | |
["SUCCESS: " => sub { my $self = shift; | |
$result = $self->after(); | |
exp_continue; | |
}], | |
[qr/\$ / => sub { my $self = shift; | |
$self->send("exit"); | |
}], | |
[timeout => sub { $ssh->soft_close(); | |
die "FAILED: Process to pull snoop file timed out."; | |
}], | |
) or die "FAILED: to do expect command.\n"; | |
$ssh->soft_close(); | |
return $result; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment