Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Bad file descriptor |
|
Author |
|
antares
Joined: 13 Oct 2010 Posts: 2 Location: Bangkok
|
Posted: Wed 13 Oct '10 2:46 Post subject: Bad file descriptor |
|
|
I am trying to update text files in the root directory of my website using a Perl program in the public directory.
I can update files in the public directory with this same script but when I try in the root directory I get 'Bad file descriptor' as soon as I try to read in data. The files are text files set to 0666 permissions.
These problem files in my root directory are regularly read from by crontab.
Is there some sort of system like .htaccess that I need to configure?
Thanks for any help in this matter.
Peace from antares
#############################################
Code to change to root directory:
chdir "/home/deliver";
Code to open the file:
open(DATABASE,"<database.txt") || die "Can't open db to read records for pwd check at profile update $!\n";
Code to access handle:
$active_file = "DATABASE";
Code to read:
read($active_file,$record,300); |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Wed 20 Oct '10 10:33 Post subject: |
|
|
Is it right that there is a < in the file name? <database.txt |
|
Back to top |
|
VoodooMill
Joined: 11 Jan 2007 Posts: 60
|
Posted: Wed 20 Oct '10 19:19 Post subject: Re: Bad file descriptor |
|
|
antares wrote: | I am trying to update text files in the root directory of my website using a Perl program in the public directory.
I can update files in the public directory with this same script but when I try in the root directory I get 'Bad file descriptor' as soon as I try to read in data. The files are text files set to 0666 permissions.
These problem files in my root directory are regularly read from by crontab.
Is there some sort of system like .htaccess that I need to configure?
Thanks for any help in this matter.
Peace from antares
#############################################
Code to change to root directory:
chdir "/home/deliver";
Code to open the file:
open(DATABASE,"<database.txt") || die "Can't open db to read records for pwd check at profile update $!\n";
Code to access handle:
$active_file = "DATABASE";
Code to read:
read($active_file,$record,300); |
I see this error once in a while on files I repeatedly open, however it doesn't seem to have a negative impact on my ability to use the file. because the only downside seems to be that error message I've not spent much time looking into it to get rid of it. As my other priorities subside and I find a solution I'll post it here. |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 20 Oct '10 21:42 Post subject: |
|
|
Perl open for read
open(DATABASE,"database.txt") || die "Can't open db to read records for pwd check at profile update $!\n";
Perl open for write
open(DATABASE,">database.txt") || die "Can't open db to read records for pwd check at profile update $!\n";
Perl open for append
open(DATABASE,">>database.txt") || die "Can't open db to read records for pwd check at profile update $!\n";
James got it right, the < is the wrong direction |
|
Back to top |
|
antares
Joined: 13 Oct 2010 Posts: 2 Location: Bangkok
|
Posted: Thu 21 Oct '10 2:28 Post subject: Thanks for thoughts |
|
|
Thank you for your thoughts on this, which BTW is still unresolved.
James Blond and gl smith - The < symbol means the file is being opened for input (read) only; it is not part of the file name. I believe the < is essential to read the file.
Voodoo Mill - Yes, there may be something in that. I read about 'Bad ioctl for device' and that seems to work in that way: if you investigate the error when the file isn't being opened or closed you get the error, but if you investigate when the file is being opened it disappears. It seems it's not really a problem at all!
All - I have rewritten the code to this, which stops the error, but I still don't know why the first way doesn't work. TMTOWTDI rules OK!
$active_file = "DATABASE";
$fileto_open = "<database.txt";
open ($active_file,"$fileto_open") || die "Can't open $fileto_open to read customers' details in root area $!\n"; |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Sun 24 Oct '10 7:46 Post subject: |
|
|
antares, you are correct as < is documented as being equal to no symbol and read mode. Next time I open a file I'll try it. |
|
Back to top |
|
|
|
|
|
|