Unlink help

Discussion in 'Perl Misc' started by Dave Saville, Feb 23, 2013.

  1. Dave Saville

    Dave Saville Guest

    I have a perl script that cleans up temporary directories at boot. If
    a file in one of those directories is read only I get a "permission
    denied" message from unlink. Note this is not a *nix or Windows
    system. If OTOH I cd to said directory and issue "rm -f *" they go
    without a murmur.

    Can unlink be made to behave like "rm -f" or do I have to use the
    command in backticks?

    TIA
     
    Dave Saville, Feb 23, 2013
    #1
    1. Advertisements

  2. Dave Saville

    Dave Saville Guest

    My mistake - it is not files that are read only. I can see no
    difference between files it will delete and those it won't It usually
    happens when it is trying to delete an unloaded tarball - some of the
    files give "permission denied".
     
    Dave Saville, Feb 23, 2013
    #2
    1. Advertisements

  3. Dave Saville

    Dave Saville Guest

    Hi Ben
    Thanks for the tip to use system rather than backticks. But I don't
    think permissions has anything to do with it. For instance:

    [T:\tmp\openjdk6_b27_jre_os2_ga5-20130217]ls -l
    total 192
    -rw-rw-rw- 1 root 0 1530 Feb 17 02:30 ASSEMBLY_EXCEPTION
    drwxrwxrwx 1 root 0 0 Feb 23 12:11 bin
    -rw-rw-rw- 1 root 0 7526 Feb 17 00:18 CHANGES.OS2
    drwxrwxrwx 1 root 0 0 Feb 23 12:11 lib
    -rw-rw-rw- 1 root 0 19610 Feb 17 02:30 LICENSE
    -rw-rw-rw- 1 root 0 13299 Feb 17 00:41 README.OS2
    -rw-rw-rw- 1 root 0 129126 Feb 17 02:30 THIRD_PARTY_README

    I run my script and afterwards:

    [T:\]ls -lR /tmp/openjdk6_b27_jre_os2_ga5-20130217/
    /tmp/openjdk6_b27_jre_os2_ga5-20130217/:
    total 32
    -rw-rw-rw- 1 root 0 1530 Feb 17 02:30 ASSEMBLY_EXCEPTION
    drwxrwxrwx 1 root 0 0 Feb 23 10:39 lib
    -rw-rw-rw- 1 root 0 19610 Feb 17 02:30 LICENSE

    The script threw permission denied on those two files and some in lib
    which is why lib is still there of course - not empty.

    Upon reflection I guess it must be an OS thing - I really just posted
    here in case there was an option to unlink I did not know about.
     
    Dave Saville, Feb 23, 2013
    #3
  4. Dave Saville

    Dave Saville Guest

    On Sat, 23 Feb 2013 12:31:45 UTC, "Dave Saville"

    Well sort of - For the last few weeks I have been using a linux system
    and once again got used to believing the permissions displayed by ls.
    It would seem that I was right the first time and it is read only
    files - despite what ls was telling me. OS/2 sort of supports file
    perms although it does not do much with them. ls was saying the file
    was rw whilst attrib said read only. The odd thing is if you chmod the
    file with any old mix of perms you like ls *and* attrib reflect them.
    Ho hum. Quick fix as Ben suggested is to chmod the file 777 before
    trying to delete it.
     
    Dave Saville, Feb 23, 2013
    #4
  5. Dave Saville

    greymaus Guest

    My own thought, as most/all ssystems now are *unix or windows.
     
    greymaus, Feb 23, 2013
    #5
  6. Does OS/2 come with an "ls" command or is this a from a third party? If
    it's not a native command then I would assume that it doesn't display
    the real permissions as implementend by the OS, but some unix-like
    approximation.

    hp
     
    Peter J. Holzer, Feb 23, 2013
    #6
  7. Dave Saville

    Dave Saville Guest

    No it's a port. What I have discovered is that it stores the *nix
    perms in the file's Extended Attributes. If there are none then it
    displays -rw-rw-rw for files and drwxrwxrwx for directories. It knows
    nothing about DOSish attributes of Archive, System, Hidden & Read
    only. However, if one uses the, also ported, chmod then the EA's are
    changed for persistance *and* if the bit in question is "Read only" it
    also updates the OS attribute. Unfortunately it does not work the
    other way around. ie if one uses attrib +R foo it does not see it.

    This particular problem was un-archiving a zip with some files read
    only. The OS attribute was set but not the EA's.
     
    Dave Saville, Feb 24, 2013
    #7
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.