Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to set file permissions using PERL

 
Rr Kumaran
Ranch Hand
Posts: 548
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have below simple perl script which sets sets all permissions to all type of users.




even I tried the 'system' command like shown in above script but when I run the script I am getting an error "chmod: WARNING: can't access /home/dummyuser/dummmy.txt".

Please suggest how to programatically set permissions on files in perl.


Thanks in advance.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message seems to be saying that it simply can't access the named file. This might be for several reasons:

Does it exist? (I notice, for example, that the filename has three "m"s in it. Is that a typing error?)

Can the user running the script read/change the file (and its enclosing directory?) - try

and


The general answer is to try the commands from the command line first (making sure you are logged on as the user who runs the script), and see what happens.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic