[Raleigh-talk] Mysterious GLOB files

Jason Rice jrice at datacraftsolutions.net
Thu Jan 4 07:06:04 PST 2007


>>What directory is it creating these GLOB files in?   $baseDir? What are >>some of the directory, subdirectory, and 
>>file names?  Any funky special characters in them?
I've looked a bit more into the issue, and it is not with that loop at all (even though 'I was sure I had isolated it to that loop'). The GLOB gets created when I perform a redirection of STDOUT and STDERR. Below is a quick sample which creates the empty GLOB on my red-hat server:

open my $file_log, '>>', 'test2.log';
open STDOUT, '>>', $file_log;
open STDERR, '>>', $file_log;
select(STDOUT); $| = 1;
select(STDERR); $| = 1;
print STDOUT "STDOUT 1\n";
print STDERR "STDERR 1\n";
close STDOUT;
close STDERR;

I've attempted to dig a little around and see what the issue is. It was that I wasn't redirecting STDOUT and STDERR via a file handle the proper way. The below code has been working fine:
open my $file_log, '>>', 'test2.log';
open STDOUT, '>>&', $file_log;
open STDERR, '>>&', $file_log;
select(STDOUT); $| = 1;
select(STDERR); $| = 1;
print STDOUT "STDOUT 1\n";
print STDERR "STDERR 1\n";
close STDOUT;
close STDERR;

I had left out the duping directive or whatever you term the '&' appended to the open mode. I had always previously just redirected them via the file name directly, so had never had a need for the '&'.

Sorry for the mis-direction.

--Jason

________________________________________
From: raleigh-talk-bounces+jrice=datacraftsolutions.net at pm.org [mailto:raleigh-talk-bounces+jrice=datacraftsolutions.net at pm.org] On Behalf Of Marc Wiatrowski
Sent: Wednesday, January 03, 2007 5:11 PM
To: raleigh-talk at pm.org
Subject: Re: [Raleigh-talk] Mysterious GLOB files

What directory is it creating these GLOB files in?   $baseDir? What are some of the directory, subdirectory, and 
file names?  Any funky special characters in them?  
 
My guess is some how you are creating files named after your actual file (directory) handles, $handle_dir and/or
$sub_handle_dir, and/or $xls_handle_dir.  Maybe sneaking into the second parameter of your mv system call...
Any more of the script that may be reusing those variables?
 
marc

________________________________________
From: raleigh-talk-bounces+wia=iglass.net at pm.org [mailto:raleigh-talk-bounces+wia=iglass.net at pm.org] On Behalf Of Jason Rice
Sent: Tuesday, January 02, 2007 2:17 PM
To: raleigh-talk at pm.org
Subject: [Raleigh-talk] Mysterious GLOB files
I have a set of scripts which cycle through some directories (on a redhat linux machine) to process files. The code works fine, except for creating GLOB(0x.......) files when the scripts complete. Anyone have an idea on this?

Snippet follows:

opendir my $handle_dir, $baseDir;
# Get list of server folders
my @all_files;
my @folders = grep { not /[.][.]?|.*[.]\w+/xmsi } readdir $handle_dir;
foreach my $fld (@folders) {
            opendir my $sub_handle_dir, "$baseDir/$fld/processed";
            my @sub_folders = grep { /\d{15}/xmsi } readdir $sub_handle_dir;
            foreach my $fld2 (@sub_folders) {
                        opendir my $xls_handle_dir, 									"$baseDir/$fld/processed/$fld2/XML";
                        chdir "$baseDir/$fld/processed/$fld2/XML";
                        my @xls_files = grep { /\A.*[.]xml\z/xmsi } readdir 					$xls_handle_dir;
                        foreach my $file (@xls_files) {
                                    # Move each file to the processed 								directory structure
                                    chdir "$baseDir/$fld/processed/$fld2/";
                                    my @args = ('mv', 								"$baseDir/$fld/processed/$fld2/XML/$file", 
 					"$baseDir/$fld/processed/$fld2/XML/complete");
                                    my $ret = system(@args);
                                    if (!$ret) {
                                                #Process here
                                    }
                        }
                        closedir $xls_handle_dir;                        
            }
            closedir $sub_handle_dir;
}
closedir $handle_dir;

=======END CODE

=======BEGIN ls -l Result
-rw-r--r--    1 root     root            0 Jan  2 12:52 GLOB(0x9710bdc)
-rw-r--r--    1 root     root            0 Jan  2 12:49 GLOB(0x9d1ebdc)
-rw-r--r--    1 root     root            0 Jan  2 12:51 GLOB(0x9ee0bdc)
-rw-r--r--    1 root     root            0 Jan  2 12:50 GLOB(0x9f95bdc)
=======END ls -l Result

Thanks,
--JER


More information about the Raleigh-talk mailing list