public
Created

Quick and dirty interchange session viewer

  • Download Gist
fetch_session.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#!/bin/env perl
 
use strict;
use warnings;
 
use DBI;
use Storable qw( thaw );
use Data::Dumper;
 
my $dsn = 'dbi:mysql:[DB NAME];host=[HOST NAME];';
my $user = '[USER]';
my $pass = '[PASS]';
 
my $session = $ARGV[0];
 
my $dbh = DBI->connect($dsn, $user, $pass)
or die $DBI::errstr;
 
my $sql = q|
SELECT session
FROM sessions
WHERE code like CONCAT(?, '%')
|;
 
my $sth = $dbh->prepare($sql)
or die $dbh->errstr;
 
$sth->execute($session)
or die $sth->errstr;
 
my @results = $sth->fetchrow_array;
 
if (@results) {
my $session_data = $results[0];
print Dumper( thaw( $session_data ) ) . "\n";
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.