Hi zusammen...
Ich hab ein, sehr wahrscheinlich kleines, Problem, dass ich einfach nicht sehe... hab wohl irgendwo ein Knoten...
Jedenfalls, Code findet ihr gleich im Post, das Problem:
Aus $subdir wird nur die erste Datei ($filename) ins $Extdir/$basename kopiert, restliche Dateien im Subdir überspringt er dann einfach...
Hab ich die Klammer einer Schlaufe falsch gesetzt oder woran liegts? Ich seh echt nicht durch...
(variabeln sind schon initiiert, hab einfach unwichtige teile rausgenommen)
Code:
schon mal vielen Dank
LG
rioc
Ich hab ein, sehr wahrscheinlich kleines, Problem, dass ich einfach nicht sehe... hab wohl irgendwo ein Knoten...
Jedenfalls, Code findet ihr gleich im Post, das Problem:
Aus $subdir wird nur die erste Datei ($filename) ins $Extdir/$basename kopiert, restliche Dateien im Subdir überspringt er dann einfach...
Hab ich die Klammer einer Schlaufe falsch gesetzt oder woran liegts? Ich seh echt nicht durch...
(variabeln sind schon initiiert, hab einfach unwichtige teile rausgenommen)
Code:
Code:
my $logfile = "E:\\IXOS\\Voicerecording-test.log"; open(LOGFILE, ">$logfile") or die $!; printf LOGFILE "%4d-%02d-%02d%-02d-%02d-%02d Script started\n\n", ($year+1900),($mon+1),$mday,$hour,$min,$sec; my $dbh = DBI->connect( 'dbi:Oracle:TEST', ) || die "Database connection not made: $DBI::errstr"; my $subdir = @ARGV[0]; if (!(-e $subdir )) { die "No directory argument given or directory does not exist"}; if (-f $subdir) { die "Argument not a directory!"}; my $regkey = IXOS::ArchiveCfg::new(); $extdir = $regkey->getSetupVar( 'EXDB/EXT_DIR' ); $extdir = $extdir."\\voicerecording\\test"; opendir(SUBDIR, "$subdir") or die $!; while (my $filename = readdir(SUBDIR)) { print "1\n"; rename($subdir."/".$filename, $subdir."/".$transfilename); print "rename(".$subdir."/".$filename." ".$subdir."/".$transfilename.");\n"; $filename = $transfilename; } next if ( $filename != m/^[A-Za-z0-9]+/g ); $basename = basename($filename,$suffix); print "Basename ".$basename."\n"; @filenamecomps = split(/_/,$basename); my $sql = qq{ select docid from doclink where vrdoc = ? }; $sth = $dbh->prepare( $sql ) || die $dbh->errstr; $sth->bind_param( 1, $basename ); $sth->execute(); $sth ->bind_columns( undef, \$docid ); printf LOGFILE "DocID for ".$basename." =".$docid."\n"; $docid = ""; @sqlarg[0] = $basename; while( $sth->fetch() ) { print "2\n"; ($lsec,$lmin,$lhour,$lmday,$lmon,$lyear,$lwday,$lyday,$lisdst)=localtime(time); my $loctime = ($lyear+1900)."/".($lmon+1)."/".$lmday." ".$lhour.":".$lmin.":".$lsec; printf LOGFILE $loctime." FOUND docid ".$docid." VREC-ID ".$basename."\n", $lyear+1900,$lmon+1,$lmday,$lhour,$lmin,$lsec;; print "Docid found : ".$docid."\n"; if (length($docid) gt 1) { print "3\n"; print "docid defined - do we have to delete it?\n"; if (-M $subdir."/".$filename >= 3 ) { unlink $subdir."/".$filename; ($lsec,$lmin,$lhour,$lmday,$lmon,$lyear,$lwday,$lyday,$lisdst)=localtime(time); $loctime = ($lyear+1900)."/".($lmon+1)."/".$lmday." ".$lhour.":".$lmin.":".$lsec; printf LOGFILE $loctime." OLD FILE - Deleting File ".$basename."\n", $lyear+1900,$lmon+1,$lmday,$lhour,$lmin,$lsec; printf $loctime." OLD FILE - Deleting File ".$basename."\n", $lyear+1900,$lmon+1,$lmday,$lhour,$lmin,$lsec; } } } $sth->finish(); if (length($docid) eq 0) { print "4\n"; $docid = ""; print "processing file ".$subdir."/".$filename."\n"; if (-f $subdir."/".$filename ) { print "5\n"; ($lsec,$lmin,$lhour,$lmday,$lmon,$lyear,$lwday,$lyday,$lisdst)=localtime(time); $loctime = ($lyear+1900)."/".($lmon+1)."/".$lmday." ".$lhour.":".$lmin.":".$lsec; printf LOGFILE $loctime." target directory ".$subdir."/".$filename." exists\n"; if ( mkdir $extdir."/".$basename ) { print "Directory created ".$extdir."/".$basename."\n"; } #end of ( mkdir $extdir."/".$basename ) # Copy the file if (copy($subdir."/".$filename, $extdir."/".$basename."/")) { ($lsec,$lmin,$lhour,$lmday,$lmon,$lyear,$lwday,$lyday,$lisdst)=localtime(time); $loctime = ($lyear+1900)."/".($lmon+1)."/".$lmday." ".$lhour.":".$lmin.":".$lsec; printf LOGFILE $loctime." file ".$subdir."/".$filename." copied to ".$extdir."/".$basename."/\n"; print $loctime." file ".$subdir."/".$filename." copied to ".$extdir."/".$basename."/\n"; } # end of copy open(FLVFILE, "<$subdir\\$filename") or die $!; filecontent); $flvchecksum = int(rand(9)).$timestamp; close FLVFILE; chdir( $extdir."/".$basename."/"); if (!open CMD, ">COMMANDS") { printf LOGFILE $loctime."COULD NOT CREATE ".$extdir."/".$basename."/COMMANDS\n"; return 0; } if ( $suffix =~ m/\.flv$/ ) { printf CMD "DOCTYPE video/x-flv\n"; printf CMD "COMP data video/x-flv ".$filename."\n"; } if ($suffix =~ m/\.mp3$/ ) { printf CMD "DOCTYPE audio/mpeg\n"; printf CMD "COMP data audio/mpeg ".$filename."\n"; } if ($suffix =~ m/\.wav$/ ) { printf CMD "DOCTYPE audio/x-wav\n"; printf CMD "COMP data audio/x-wav ".$filename."\n"; } if ($suffix != m/\.wav$/ || $suffix != m/\.flv$/ || $suffix != m/\.mp3$/ ) { printf CMD "DOCTYPE application/octet-stream\n"; printf CMD "COMP data application/octet-stream ".$filename."\n"; die "Filename extension NOT allowed!"; } printf CMD "COMP ATTRLIST ATTR ATTRLIST\n"; printf CMD "ARCHIVID T1\n"; close CMD; my $flvfiletype = @filenamecomps[0]; if ( $flvfiletype == "CRM" ) { my $func2; my $sql2 = qq{ SELECT cs_voice_doc FROM sysadm.ps_cs_sperrlog_au WHERE cs_yesno_optinakt = 'Y' AND cs_voice_doc = '$basename' }; #found files $func2 = $dbh->prepare( $sql2 ) || die $dbh->errstr; $func2->execute(); $func2->bind_columns( undef, \$rv ); my @result; while (@result = $func2->fetchrow()) { printf "\n\nResult=".@result[0]."\n\n"; } if ( @result[0] != '' ) { #already archived, can be deleted unlink($extdir."/".$basename."/COMMANDS"); unlink($extdir."/".$basename."/".$filename); rmdir($extdir."/".$basename); unlink($subdir."/".$filename); } if ( @result[0] = '' ) { #we have a file we really need to archive. my $rawdate = @filenamecomps[3]; my $rawyear = substr($rawdate,0,4); my $rawmonth = substr($rawdate,4,2); my $rawday = substr($rawdate,6,2); $oldarchdate = $rawday.".".$rawmonth.".".$rawyear; } $func2->finish(); } if ( $flvfiletype == "LOT" || $flvfiletype == "LOTTO" || $flvfiletype == "LCS" || $flvfiletype == "WIN" ) { my $date_string = ctime(stat($filename)->mtime); my $date = ParseDate($date_string); my $rawyear = substr($date,0,4); my $rawmonth = substr($date,4,2); my $rawday = substr($date,6,2); $oldarchdate = $rawday.".".$rawmonth.".".$rawyear; print "file ".$filename." updated at ".$date."\n"; } if ( $flvfiletype != "LOT" || $flvfiletype != "LOTTO" || $flvfiletype != "LCS" || $flvfiletype != "WIN" ) { my $date_string = ctime(stat($filename)->mtime); my $date = ParseDate($date_string); my $rawyear = substr($date,0,4); my $rawmonth = substr($date,4,2); my $rawday = substr($date,6,2); $oldarchdate = $rawday.".".$rawmonth.".".$rawyear; print "file ".$filename." ignored at ".$date."\n"; if ( $flvfiletype != "CRM" || $flvfiletype != "LOT" || $flvfiletype != "LOTTO" || $flvfiletype != "LCS" || $flvfiletype != "WIN" ) { printf LOGFILE "Illegal Application type".$flvfiletype." not allowed for ".$basename."\n"; die "Illegal Application Type - not allowed"; } if ( $flvfiletype =~ m/^[A-Za-z]/g ) { printf LOGFILE "Application type".$flvfiletype." not allowed for ".$basename." - identifier may only consist of letters\n"; die "Application identifier may only consist of letters"; } } untie $flvchecksum; } #end of if } else { #end of test whether file may be archived (docid ne 0) print "File not found\n"; # unlink($subdir."/".$filename); } } # end of while (my $filename = readdir(SUBDIR))
LG
rioc
Comment