Gossamer Forum
Home : Products : DBMan : Installation :

Creating a flat file

Quote Reply
Creating a flat file
I am trying to create a flat file when someone adds to or madifies the db, using the following:

sub file {
open(FILE, ">>$db_script_path/msaccess.txt") | | die "I can't $!\n";
print FILE "\"$rec{'ID'}\",\"$rec{'Title'}\",\"$rec{'URL'}\"\n";
close(FILE);
}
Unfortunately, this isn't working. I tried putting it in db.cgi and the html.pl, but it doesn't work. It doesn't give an error either, so I guess the syntax is correct. Can anyone help?
Thanks. By the way. DBMan ir really great andd the support here is terrific.
--wm
Quote Reply
Re: Creating a flat file In reply to
 
Quote:
open(FILE, ">>$db_script_path/msaccess.txt") | | die "I can't $!\n";

Well it should be '| | die', you have an extra space in there. Assuming that is just a cut and paste error and your script does compile, try adding a print "Hello!" just after file close to see if the subroutine is even being run.

Otherwise the code looks ok..

Cheers,

Alex
Quote Reply
Re: Creating a flat file In reply to
I'll give it a run, thanks.
--wm
Quote Reply
Re: Creating a flat file In reply to
I've tried this. I even used exactly the same method the default logging subroutine does. Whatever I do, I cannot write anything to a file which I have created and set to 666.

Note: I also get no error messages while doing this. Has anyone figured it out yet?


Chris.
Quote Reply
Re: Creating a flat file In reply to
Problem probably is %rec goes out of scope. Try:

sub file {
# --------------------------------
my %rec = @_;
...

}

and then when you call it:

&file (%rec);

Hope this helps,

Alex