public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Perl database problem
@ 2001-10-26 16:00 Goksun Ilhan
  2001-10-27  8:31 ` Gerrit P. Haase
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Goksun Ilhan @ 2001-10-26 16:00 UTC (permalink / raw)
  To: cygwin

Hi,

I am trying to run a Perl program in cygwin. When I
create the database using dbmopen command, it looks
like it's working (it's only creating .pag file, not
.dir file). However, when I try to read something from
the database, it cannot open the file. I run the
program on a UNIX machine and it works. Is there way
to run that program using cygwin? 

thanks
Goksun

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Perl database problem
  2001-10-26 16:00 Perl database problem Goksun Ilhan
@ 2001-10-27  8:31 ` Gerrit P. Haase
  2001-10-27 15:40 ` Gerrit P. Haase
  2001-10-27 17:53 ` Charles Wilson
  2 siblings, 0 replies; 4+ messages in thread
From: Gerrit P. Haase @ 2001-10-27  8:31 UTC (permalink / raw)
  To: Goksun Ilhan; +Cc: cygwin

Hallo Goksun,

Am 2001-10-27 um 00:59 schriebst du:

> I am trying to run a Perl program in cygwin. When I
> create the database using dbmopen command, it looks
> like it's working (it's only creating .pag file, not
> .dir file). However, when I try to read something from
> the database, it cannot open the file. I run the
> program on a UNIX machine and it works. Is there way
> to run that program using cygwin? 

What program? Please post it or a useful snippet along
with the output of:

    $ cygcheck -svr

> Do You Yahoo!?

No Hayoo!.

Ciao,

Gerrit P. Haase                            mailto:gp@familiehaase.de
-- 
=^..^=


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Perl database problem
  2001-10-26 16:00 Perl database problem Goksun Ilhan
  2001-10-27  8:31 ` Gerrit P. Haase
@ 2001-10-27 15:40 ` Gerrit P. Haase
  2001-10-27 17:53 ` Charles Wilson
  2 siblings, 0 replies; 4+ messages in thread
From: Gerrit P. Haase @ 2001-10-27 15:40 UTC (permalink / raw)
  To: Goksun Ilhan; +Cc: cygwin

Hallo Goksun,

Am 2001-10-27 um 00:59 schriebst du:

> I am trying to run a Perl program in cygwin. When I
> create the database using dbmopen command, it looks
> like it's working (it's only creating .pag file, not
> .dir file). However, when I try to read something from
> the database, it cannot open the file. I run the
> program on a UNIX machine and it works. Is there way
> to run that program using cygwin? 

#!/usr/bin/perl -w
# recipe 14.1 from the 'Perl Cookbook'

use DB_File;

$db = '/tmp/userstats.db';

# use tie or dbmopen, as you like it,
# both works for me (on cygwin!)
# tie(%db, 'DB_File', $db)
#        or die "Cannot open DB_File $db: $!\n";

dbmopen (%db, $db, 0666)
        or die "Cannot open DB_File $db: $!\n";

if (@ARGV) {
    if ("@ARGV" eq "ALL") {
            @ARGV = sort keys %db;
    }
    foreach $user (@ARGV) {
            print "$user\t$db{$user}\n";
    }
} else {
    @who = `who`;             # execute who(1)
    if ($?) {
            die "Cannot execute who(1): $?\n";
    }
    # extract usernames and update
    foreach $line (@who) {
            $line =~ /^(\S+)/;
            die "error in who(1) output: $line\n"
              unless $1;
            $db{$1}++;
            }
}

# untie %db;
dbmclose %db;

# Ciao,

# Gerrit P. Haase                            mailto:gp@familiehaase.de
-- 
=^..^=


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Perl database problem
  2001-10-26 16:00 Perl database problem Goksun Ilhan
  2001-10-27  8:31 ` Gerrit P. Haase
  2001-10-27 15:40 ` Gerrit P. Haase
@ 2001-10-27 17:53 ` Charles Wilson
  2 siblings, 0 replies; 4+ messages in thread
From: Charles Wilson @ 2001-10-27 17:53 UTC (permalink / raw)
  To: Goksun Ilhan; +Cc: cygwin

On Fri, 26 Oct 2001, Goksun Ilhan wrote:
> I am trying to run a Perl program in cygwin. When I
> create the database using dbmopen command, it looks
> like it's working (it's only creating .pag file, not
> .dir file). However, when I try to read something from
> the database, it cannot open the file. I run the
> program on a UNIX machine and it works. Is there way
> to run that program using cygwin?

cygwin's perl uses gdbm to provide back end database services (including
NDBM:: GDBM:: and ODBM::).  The dbmopen() command that you reference
indicates that you are using the NDBM:: flavor.  When gdbm is used in its
ndbm-emulation mode, it stores the data in the .pag file -- but creates a
.dir file as a HARD LINK so that the on-disk footprint of this
gdbm-masquerading-as-ndbm is the same as REAL ndbm databases.

However, hard links don't work on FAT drives, only NTFS drives.  (No, we
can't change gdbm to use symlinks instead -- the hard link is necessary
because REAL ndbm expects both files to have the same timestamp.  With
hardlinks, they will.  with symlinks, they won;t).

Solution?  Don't use ndbm.  (NDBM::)  Use gdbm.

Or, make sure your databases are created on an NTFS drive.

--Chuck



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-10-27 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-26 16:00 Perl database problem Goksun Ilhan
2001-10-27  8:31 ` Gerrit P. Haase
2001-10-27 15:40 ` Gerrit P. Haase
2001-10-27 17:53 ` Charles Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).