Annotation of wpscripts/zstatus/zstatus.pl, Revision 1.4
1.1 yason 1: #!/usr/bin/perl
1.4 ! yason 2: # $Id: zstatus.pl,v 1.3 2011/12/21 09:25:22 yason Exp $
1.1 yason 3: use DBI;
4:
1.2 yason 5: my $DB_SERVER = "pdc"; # from /usr/local/etc/freetds.conf
6: my $DB_USER = "sa";
7: my $DB_PASS = "aekghbynflvby";
1.1 yason 8: my $dsn = "DBI:Sybase:server=$DB_SERVER";
9: my $dbh;
10: my $sth;
11: my $numcard;
12: my $type;
13: my $value;
14: my @status;
15:
1.4 ! yason 16: if(scalar(@ARGV) != 3 || $ARGV[1] ne "tiff" && $ARGV[1] ne "proba" && $ARGV[1] ne "tt" && $ARGV[1] ne "zjpeg" && $ARGV[1] ne "pjpeg")
1.1 yason 17: {
18: print "Usage:\n";
1.4 ! yason 19: print "zstatus <NumCard> <tiff|proba|tt|zjpeg|pjpeg> <value>\n";
1.1 yason 20: exit(-1);
21: }
22: $numcard = shift;
23: $type = shift;
24: $value = shift;
25: if($value != 0 && $value != 1)
26: {
27: print "Status value out of range: valid values are 0 or 1\n";
28: exit(-1);
29: }
30:
31: $dbh = DBI->connect($dsn, $DB_USER, $DB_PASS) or die("Can not connect to database!");
1.2 yason 32: $dbh->do("use full_print");
1.1 yason 33:
1.2 yason 34: $sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=0") if($type eq "tiff");
35: $sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=1") if($type eq "proba");
1.3 yason 36: $sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=2") if($type eq "tt");
1.4 ! yason 37: $sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=3") if($type eq "zjpeg");
! 38: $sth = $dbh->prepare("SELECT ID,status from upload_files WHERE numcard=$numcard AND type_file=4") if($type eq "pjpeg");
1.1 yason 39: $sth->execute( );
40:
41: @status = ($sth->fetchrow_array( ));
42: if(!$status[0])
43: {
44: print "$type with NumCard=$numcard not found in the database!\n";
45: exit(-1);
46: }
47:
1.2 yason 48: $sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=0") if($type eq "tiff");
49: $sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=1") if($type eq "proba");
1.3 yason 50: $sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=2") if($type eq "tt");
1.4 ! yason 51: $sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=3") if($type eq "zjpeg");
! 52: $sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=4") if($type eq "pjpeg");
1.1 yason 53: $sth->execute( ) or die("Can not execute SQL");
54: print "status changed from $status[1] " . ($status[1] == 0 ? "(NOT SENT)" : "(SENT)") . " to $value " . ($value == 1 ? "(SENT)" : "(NOT SENT)") . "\n";
55:
56:
CVSweb