in reply to Can't create file

How about:
open FILE, "+>", "/var/named/$domain.db" or die "Could not open file $domain.db: $!\n";
The variable $! contains the operation system error message, in case something went wrong ;-)

Secondly, maybe you should check if the variable $domain is defined and has content?

to ask a question is a moment of shame
to remain ignorant is a lifelong shame

Replies are listed 'Best First'.
Re^2: Can't create file
by sluttysysadmin (Initiate) on Oct 05, 2009 at 16:00 UTC
    Hello insaniac, I made the changes you suggested. It still doesn't work. I can see the following error in the Apache error log. [Mon Oct 05 19:57:18 2009] [error] [client 192.168.2.4] Could not open file test123.com.db: Permission denied, referer: http://192.168.2.99/a.html Any views ?
      I think the error message is pretty clear; Permission denied!!!

      So, you slutty sysadmin, fix the permissions on that directory or file! (i'm guessing that your Apache user doesn't have write permission there)

      to ask a question is a moment of shame
      to remain ignorant is a lifelong shame

        Hey Insaniac, I know it will work if I change the ownership of the directory /var/named to root.nobody but I don't want to change the ownership. Is there any way I can run the script itself as root.named or as a root user instead of 'nobody'? Thanks for the help till now.