File: [local] / wpscripts / zstatus / zstatus.pl (download)
Revision 1.4, Thu Feb 2 15:06:19 2012 UTC (12 years, 4 months ago) by yason
Branch: MAIN
CVS Tags: HEAD Changes since 1.3: +7 -5 lines
split jpeg into zjpeg and pjpeg
|
#!/usr/bin/perl
# $Id: zstatus.pl,v 1.4 2012/02/02 15:06:19 yason Exp $
use DBI;
my $DB_SERVER = "pdc"; # from /usr/local/etc/freetds.conf
my $DB_USER = "sa";
my $DB_PASS = "aekghbynflvby";
my $dsn = "DBI:Sybase:server=$DB_SERVER";
my $dbh;
my $sth;
my $numcard;
my $type;
my $value;
my @status;
if(scalar(@ARGV) != 3 || $ARGV[1] ne "tiff" && $ARGV[1] ne "proba" && $ARGV[1] ne "tt" && $ARGV[1] ne "zjpeg" && $ARGV[1] ne "pjpeg")
{
print "Usage:\n";
print "zstatus <NumCard> <tiff|proba|tt|zjpeg|pjpeg> <value>\n";
exit(-1);
}
$numcard = shift;
$type = shift;
$value = shift;
if($value != 0 && $value != 1)
{
print "Status value out of range: valid values are 0 or 1\n";
exit(-1);
}
$dbh = DBI->connect($dsn, $DB_USER, $DB_PASS) or die("Can not connect to database!");
$dbh->do("use full_print");
$sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=0") if($type eq "tiff");
$sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=1") if($type eq "proba");
$sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=2") if($type eq "tt");
$sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=3") if($type eq "zjpeg");
$sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=4") if($type eq "pjpeg");
$sth->execute( );
@status = ($sth->fetchrow_array( ));
if(!$status[0])
{
print "$type with NumCard=$numcard not found in the database!\n";
exit(-1);
}
$sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=0") if($type eq "tiff");
$sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=1") if($type eq "proba");
$sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=2") if($type eq "tt");
$sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=3") if($type eq "zjpeg");
$sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=4") if($type eq "pjpeg");
$sth->execute( ) or die("Can not execute SQL");
print "status changed from $status[1] " . ($status[1] == 0 ? "(NOT SENT)" : "(SENT)") . " to $value " . ($value == 1 ? "(SENT)" : "(NOT SENT)") . "\n";