Skip to content

Instantly share code, notes, and snippets.

@HitScan
Created September 4, 2014 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HitScan/0bddf6e454481438f27d to your computer and use it in GitHub Desktop.
Save HitScan/0bddf6e454481438f27d to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use OpenILS::Utils::Cronscript;
#$OpenILS::Utils::Cronscript::debug = 1;
my $core = OpenILS::Utils::Cronscript->new({nolockfile=>1});
my $account = {
username => 'WHO',
password => 'WHAT',
workstation => 'WHERE'
};
my $authtoken = $core->authenticate($account);
my $circ = $core->session('open-ils.circ');
my $evt = undef;
my $count = 0;
my $errs = 0;
while(<STDIN>) {
chomp;
eval {
#print "Marking $_ lost.\n";
$evt = $circ->request('open-ils.circ.circulation.set_lost', $authtoken, {barcode=>"$_"})->gather();
if ($evt) {
$core->warn_event($evt);
}
1;
} or do {
my $e = $@;
print "Ouch! Got $e; trying to continue.\n";
$errs++;
};
$count++;
if ($count % 100 == 0) {
print "Processed $count items.\n";
sleep 5;
}
}
$core->logout($authtoken);
print "Processed $count total items; recieved $errs system errors.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment