[BACK]Return to zstatus.pl CVS log [TXT][DIR] Up to [local] / wpscripts / zstatus

Annotation of wpscripts/zstatus/zstatus.pl, Revision 1.1

1.1     ! yason       1: #!/usr/bin/perl
        !             2: # $Id$
        !             3: use DBI;
        !             4:
        !             5: my $DB_SERVER = "MSSQL";  # from /usr/local/etc/freetds.conf
        !             6: my $DB_USER = "it_men";
        !             7: my $DB_PASS = "itmen712";
        !             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:
        !            16: if(scalar(@ARGV) != 3 || $ARGV[1] ne "tiff" && $ARGV[1] ne "jpeg" && $ARGV[1] ne "proba")
        !            17: {
        !            18:     print "Usage:\n";
        !            19:     print "zstatus <NumCard> <tiff|jpeg|proba> <value>\n";
        !            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!");
        !            32: $dbh->do("use Manager");
        !            33:
        !            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 "jpeg");
        !            36: $sth = $dbh->prepare("SELECT ID,Status from upload_files WHERE NumCard=$numcard AND type_file=2") if($type eq "proba");
        !            37: $sth->execute( );
        !            38:
        !            39: @status = ($sth->fetchrow_array( ));
        !            40: if(!$status[0])
        !            41: {
        !            42:     print "$type with NumCard=$numcard not found in the database!\n";
        !            43:     exit(-1);
        !            44: }
        !            45:
        !            46: $sth = $dbh->prepare("UPDATE upload_files SET Status=$value WHERE NumCard=$numcard AND type_file=0") if($type eq "tiff");
        !            47: $sth = $dbh->prepare("UPDATE upload_files SET Status=$value WHERE NumCard=$numcard AND type_file=1") if($type eq "jpeg");
        !            48: $sth = $dbh->prepare("UPDATE upload_files SET Status=$value WHERE NumCard=$numcard AND type_file=2") if($type eq "proba");
        !            49: $sth->execute( ) or die("Can not execute SQL");
        !            50: print "status changed from $status[1] " . ($status[1] == 0 ? "(NOT SENT)" : "(SENT)") . " to $value " . ($value == 1 ? "(SENT)" : "(NOT SENT)") . "\n";
        !            51:
        !            52:

CVSweb