473,390 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Bad file descriptor

30
Hi, everyone

I met a "Bad file descriptor" problem, and I test my var, it is right in the proceeding. I dont know why, any suggestion is helpful

[
Expand|Select|Wrap|Line Numbers
  1. $dir = "d:/1";
  2. #print "Text files in $dir are:\n";
  3. opendir(HANDLE, $dir) or die "Can't open $dir: $!";
  4. while( defined ($file = readdir HANDLE) ) 
  5. {
  6.     next if $file =~ /^\./;
  7.  
  8.     $dir2=$dir."/".$file;
  9.  
  10.     &removedir($dir2);   
  11. }
  12. closedir(HANDLE);
  13.  
  14. sub removedir
  15. {
  16.  
  17.     opendir(HANDLE2,$_[0]) or die $!;
  18.     #print "$_[0]\n";
  19.     while(defined ($file2=readdir HANDEL2) or die $!)
  20.     {
  21.         print "$_[0]/$file2\n";
  22.         next if $file2=~ /^\./;
  23.         if(-d "$_[0]/$file2")
  24.         {
  25.  
  26.             $_[0].="/".$file2;
  27.             &removedir($_[0]);
  28.  
  29.         }
  30.         unlink "$_[0]/$file2";
  31.  
  32.     }
  33.     closedir(HANDLE2);
  34.     rmdir $_[0] ;
  35.  
  36. }
"while(defined ($file2=readdir HANDEL2) or die $!)" <------ "bad file descriptor" died out here.

Thanks in advance.
Oct 8 '08 #1
3 9425
KevinADC
4,059 Expert 2GB
look at how you have HANDEL2 spelled
Oct 8 '08 #2
anklos
30
look at how you have HANDEL2 spelled
I'm sorry for inattention.

Thank you, Kevin.
Oct 8 '08 #3
KevinADC
4,059 Expert 2GB
I'm sorry for inattention.

Thank you, Kevin.
We've all done it. Glad it was an easy one.
Oct 8 '08 #4

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

Similar topics

9
by: wordsender | last post by:
Hey guys, I can't figure this one out, why is this simple script giving me problems? logfile=file(r'test.txt','w') logfile.write('datetime') test=logfile.readlines() When I run it I get...
8
by: Joe | last post by:
Hi, I want to use the C library function mkstemp. It returns a unix file descriptor (int) to an open file. How do I convert the file descriptor to a valid ofstream object? Thanks, Joe
6
by: Siddharth Taneja | last post by:
Hi, I have a very simple prg over here, trying to read the lines of a file #include <iostream> #include <fstream> #include <iostream> #include <string> using namespace std;
3
by: gipsy boy | last post by:
Given a file descriptor (from a network socket, for instance), I want to have an iostream that reads/writes to it, so I can push and read data in the traditional way : sockStream << "<some...
4
by: CSN | last post by:
At startup this appears in the log: WARNING: dup(0) failed after 3195 successes: Bad file descriptor What does it mean? __________________________________________________
7
by: news | last post by:
Recently our mail from our e-commerce site has been rejected by AOL due to an IP block because someone was using our PHP scripts to send spam. Well, I got that fixed. But our legitimate...
4
by: darrin.skinner | last post by:
Hi all, How can I open a file/pipe to something other than STDOUT/STDERR? I.e. I want to write to file descriptor # 3. fopen("php://std3"... does not work. fopen("/dev/ttyS3"... does not...
3
by: akaarj | last post by:
I am using Linux gcc 4.1.1 version I have a file descriptor and I want to have a FILE* pointer to the file from the file descriptor. OR if I can have the file name using the file descriptor.....
5
by: yinglcs | last post by:
I have a c/c++ program in linux. I would like to know if I kill my program (e.g. exit(1)), will it release all the file descriptors my program held (regardless if I call close(fd) of each file...
9
by: Bill David | last post by:
I know it's very strange to do that since we have the file name when we call: int open(const char *pathname, int oflag,...); And we can store the file name for later usage. But I just wonder if...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.