Created
May 24, 2012 21:24
-
-
Save justino/2784323 to your computer and use it in GitHub Desktop.
Quick and dirty interchange session viewer
This file contains 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
#!/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"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment