REQUEST: Problem with Perl (Win32) on Windows98SE and reading files

Discussion in 'Perl Misc' started by Jeff, Dec 12, 2003.

  1. Jeff

    Jeff Guest

    Hi all

    I don't usually follow these groups so replies to my email
    (jeffcrow(AT)tpg.com.au) would be preferred in addition to posts to the
    group. Thanks.

    I am having problems reading a file from a perl script running under
    windows98se. This seems to be a recent problem as I've had several scripts
    in the past work fine. The general flow of data is;

    Data in a spreadsheet in OpenOffice.org 1.1 is output as text file to a dir.
    A perl script is kicked off to read all files in the dir and process the
    data for output as webpages. I was trying to read files in a dir in a
    scalar context but when I was having problems I changed to an array context.
    A snip of code is now;

    opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
    @files = readdir(OUTDOOR);
    closedir(OUTDOOR);
    foreach $file (@files) {
    TEST READABLE
    IF !READABLE
    CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
    }

    What I get as output is 'File is not readable and permissions can't be
    changed'. I have checked the directories in the path (\auto\process0) to
    ensure they are visible and readable. I have checked the files in the dir
    are visible and readable. I have opened the files in a text editor and they
    are readable and plain text. I have opened a console/MS-DOS Prompt window
    and opened the file with "edit test.out" and viewed the contents fine.

    I wrote a perl script that creates some file in the directory and puts some
    text into the file. I then close the file, sleep for 30 seconds and then
    readdir(directory) and again the files are reported as NOT readable and
    permissions can't be changed. Again, the file I output is fine and readable
    in consoles, editors etc.

    I deleted the version of perl I was using (Activestate 5.?? I can't recall)
    cleaned the REGISTRY and installed a GNU perl 5.004_02 and still the same
    problem.

    Short of running this under LINUX as I would ordinarily do, can any win32
    Perl guru offer any assistance?

    Thanks in advance for any and all for assistance provided.
    Jeff
     
    Jeff, Dec 12, 2003
    #1
    1. Advertising

  2. Jeff

    Jay Tilton Guest

    "Jeff" <jeffcrow(AT)tpg.com.au> wrote:

    : opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
    : @files = readdir(OUTDOOR);
    : closedir(OUTDOOR);
    : foreach $file (@files) {
    : TEST READABLE
    : IF !READABLE
    : CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
    : }
    :
    : What I get as output is 'File is not readable and permissions can't be
    : changed'.

    Murphy is telling me the problem is somewhere in those paraphrased lines.
    It's impossible to diagnose boguscode accurately.

    You've probably made a mistake using the return from readdir()--a mistake
    so common that half of the documentation for readdir() is there to ensure
    you don't make it.

    [...]
    If you're planning to filetest the return values out of a
    "readdir", you'd better prepend the directory in question.
    Otherwise, because we didn't "chdir" there, it would have
    been testing the wrong file.
     
    Jay Tilton, Dec 13, 2003
    #2
    1. Advertising

  3. Jeff <jeffcrowtpg.com.au> wrote:

    > @files = readdir(OUTDOOR);


    > TEST READABLE


    > Thanks in advance for any and all for assistance provided.



    You should read the documentation for the functions that you use.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Dec 13, 2003
    #3
  4. (Tad McClellan) wrote in message news:<>...
    > Jeff <jeffcrowtpg.com.au> wrote:
    >
    > > @files = readdir(OUTDOOR);

    >
    > > TEST READABLE

    >
    > > Thanks in advance for any and all for assistance provided.

    >
    >
    > You should read the documentation for the functions that you use.


    Tad --

    There's only been one "perfect" person I know of and we "nailed him to
    a cross"....

    Jeff --
    You might for check/post http://perlmonks.com, maybe they'll remember
    a time when they didn't not readying every man page for every function
    for every program they wrote.

    Sorry I cann't be of more help.

    DJJ
     
    David Jackson, Dec 14, 2003
    #4
  5. Jeff

    Matt Garrish Guest

    "Jeff" <jeffcrow(AT)tpg.com.au> wrote in message
    news:3fda88a4$...
    >
    > opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
    > @files = readdir(OUTDOOR);
    > closedir(OUTDOOR);
    > foreach $file (@files) {
    > TEST READABLE
    > IF !READABLE
    > CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
    > }
    >


    It would help if you hadn't left out the most important part of the code. My
    guess is that you're either trying to change the permissions on '.' and
    '..', or your running the script in a different directory from the files and
    not prepending the full path. But unless you'd care to share the rest of
    your code, there's not much anyone can do for you.

    Matt
     
    Matt Garrish, Dec 14, 2003
    #5
  6. David Jackson <> wrote:
    > (Tad McClellan) wrote in message news:<>...
    >> Jeff <jeffcrowtpg.com.au> wrote:
    >>
    >> > @files = readdir(OUTDOOR);

    >>
    >> > TEST READABLE

    >>
    >> > Thanks in advance for any and all for assistance provided.

    >>
    >>
    >> You should read the documentation for the functions that you use.

    ^^^^^^^^^^^^
    ^^^^^^^^^^^^

    > You might for check/post http://perlmonks.com, maybe they'll remember
    > a time when they didn't not readying every man page for every function
    > for every program they wrote.



    We don't expect that here either. You're making shit up.


    > Sorry I cann't be of more help.



    If he reads the documentation for the function that he is using
    then he will have the solution to his problem.

    I helped him, you did not help him.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Dec 14, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vinay Gupta
    Replies:
    2
    Views:
    1,122
    Michael Schlenker
    Jul 27, 2004
  2. Brian Birtle
    Replies:
    2
    Views:
    2,098
    John Saunders
    Oct 16, 2003
  3. Bob Chapman

    pywin32 201.1 Windows98SE Problem?

    Bob Chapman, May 29, 2004, in forum: Python
    Replies:
    4
    Views:
    468
    Bob Chapman
    May 30, 2004
  4. Replies:
    0
    Views:
    798
  5. Michael Edmonson

    Win32::SAPI4 question (Win32 events and Perl)

    Michael Edmonson, Feb 28, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    193
    Michael Edmonson
    Feb 28, 2004
Loading...

Share This Page