Unlink help

D

Dave Saville

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
 
D

Dave Saville

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?

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".
 
D

Dave Saville

Hi Ben
What sort of system is it?
OS/2

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.
 
D

Dave Saville

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

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.

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.
 
P

Peter J. Holzer

What sort of system is it?
OS/2
[...]
[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

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
 
D

Dave Saville

Quoth "Dave Saville" <[email protected]>:
On Sat, 23 Feb 2013 09:49:38 UTC, "Dave Saville"
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.

What sort of system is it?
OS/2
[...]
[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

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.

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top