Annotation of wpscripts/zstatus/zstatus.pl, Revision 1.2
1.1 yason 1: #!/usr/bin/perl
1.2 ! yason 2: # $Id: zstatus.pl,v 1.1.1.1 2011/06/03 09:28:47 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.2 ! yason 16: if(scalar(@ARGV) != 3 || $ARGV[1] ne "tiff" && $ARGV[1] ne "proba")
1.1 yason 17: {
18: print "Usage:\n";
1.2 ! yason 19: print "zstatus <NumCard> <tiff|proba> <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.1 yason 36: $sth->execute( );
37:
38: @status = ($sth->fetchrow_array( ));
39: if(!$status[0])
40: {
41: print "$type with NumCard=$numcard not found in the database!\n";
42: exit(-1);
43: }
44:
1.2 ! yason 45: $sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=0") if($type eq "tiff");
! 46: $sth = $dbh->prepare("UPDATE upload_files SET status=$value WHERE numcard=$numcard AND type_file=1") if($type eq "proba");
1.1 yason 47: $sth->execute( ) or die("Can not execute SQL");
48: print "status changed from $status[1] " . ($status[1] == 0 ? "(NOT SENT)" : "(SENT)") . " to $value " . ($value == 1 ? "(SENT)" : "(NOT SENT)") . "\n";
49:
50:
CVSweb