468,315 Members | 1,404 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

Can't locate object method "fd" via package "SDBM_File"

6 jobs are running at the same time and accessing same dbm file for writing and reading. These are daily jobs and failing only some times not regularly. So i thought of this is just because of dead lock situation. So i tried to put flock here in the following code. But i got the following error.

Can't locate object method "fd" via package "SDBM_File"


Can any body help me in this case.
Expand|Select|Wrap|Line Numbers
  1.  use strict ;
  2. use warnings ;
  3. use SDBM_File ;
  4. use Fcntl ;
  5. use vars qw($ctl);
  6.  
  7. my  $dir;
  8. my $LOCK_EX = 2;
  9. # determine application base directory
  10.     require("rupBase.pl");
  11.     $dir = &rupBase($0);
  12.  
  13. #---load supplemental routines
  14. #   $SLAYER_ON = 1;            #-- slayer inititalized if variable defined --#
  15.     push(@INC,$dir);
  16.     require("utlInitPerl.pl") || die "could not locate 'utlInitPerl.pl'";
  17. #
  18. #----------------------------End of Common Code------------------------------
  19. #
  20. my  $date;
  21.     chop($date=`date '+%Y%m%d.%H%M`);
  22.  
  23. my  $dpc       = $$ctl{MTT_JURISDICTION};
  24. my  $fileName  = $$ctl{MTT_OUTPUT_EOP_XPORT_OUT}."/GAPSOUT.".$date;
  25. my  $fileRecall;
  26. my  $tName     = $$ctl{MTT_STAT_DIR}."/FTP_FILE_NAMES";
  27. my  $cycnum = '';
  28. my  $cycFile = $$ctl{MTT_CYCLE_FILE};
  29. my  $javaHome=$ENV{JAVA_HOME};
  30. my  $db;
  31. my  $stat;
  32. my  %FILE_NAMES;
  33.  
  34.     $ENV{'MTT_CYCLE_FILE'} = $cycFile;
  35.     $ENV{'GAPSOUT'} = "$fileName";
  36.  
  37.     $ENV{'PATH'}="$javaHome/bin:$javaHome/jre/bin:$ENV{PATH}";
  38.  
  39. #----------------------------------------------------------------------------
  40. # get cycle number
  41. #----------------------------------------------------------------------------
  42.  
  43.     open(FILE,"<$cycFile");
  44.     { local $/ = undef;
  45.       my $data = <FILE>;
  46.       $cycnum = substr($data,11,7);
  47.       print "Cycle Number = $cycnum\n";
  48.     }
  49.     close(FILE);
  50.  
  51.  
  52.     print "\n======================Start Java======================\n";
  53. my  $cmd = "java -DDPCH=$dpc -DCycleDt=$cycnum GapsOutRpt $fileName";
  54.     print "========================End Java=======================\n\n";
  55.     print "$cmd\n";
  56.     $! = system("$cmd");
  57.     $stat = $!>>8;
  58.     if ($stat > 4) {
  59.         &postlude($stat,$!);
  60.         exit $stat;
  61.     }
  62.  
  63. my  $i = 0;
  64. local *DBM;
  65.     while ($i++ < 5) {
  66.         $db = tie(%FILE_NAMES, 'SDBM_File', $tName, O_RDWR|O_CREAT, 0666)
  67.             or die "Cannot open $tName: $!\n" ;
  68.  
  69.         my $fd = $db->fd;
  70.         open DBM, "+<&=$fd" or die "Could not dup DBM for lock: $!";
  71.         flock DBM, $LOCK_EX;
  72.         undef $db;
  73.         $FILE_NAMES{'GAPSOUT'} = $fileName;
  74.         $fileRecall = $FILE_NAMES{'GAPSOUT'};
  75.  
  76.         if ($fileRecall eq $fileName) {
  77.             print "$i: DB update successful: $fileName\n";
  78.             last;
  79.  
  80.         } else {
  81.             print "$i: DB update failed: sleep (1): try again\n";
  82.             sleep (1);
  83.         }
  84.  
  85.     }
  86.  
  87.     $stat = $!>>8;
  88.     if ($stat != 0) {
  89.         &postlude($stat,$!);
  90.     }
  91.  
  92. exit $stat;
  93.  
Mar 19 '08 #1
1 1723
KevinADC
4,059 Expert 2GB
This line is the source of the error:

my $fd = $db->fd;

what is the fd method supposed to do? As far as I know the SDBM_File module has no usable methods.
Mar 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by sonu | last post: by
3 posts views Thread by Steve Richter | last post: by
ronnil
5 posts views Thread by ronnil | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.