A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
REST with Spring (video course)
this week in the
Not able to set file permissions using PERL
Joined: Sep 17, 2001
Nov 18, 2005 01:35:00
I have below simple perl script which sets sets all permissions to all type of users.
#!/usr/bin/perl $status = `chmod 755 /home/dummyuser/dummmy.txt`; print ("\$status:$status"); system ("chmod 777 dummmy.txt");
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.
Joined: Jan 07, 1999
Nov 19, 2005 14:40:00
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
ls -l /home/dummyuser /home/dummyuser/dummmy.txt
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.
Read about me at frankcarver.me
Raspberry Alpha Omega
Frank's Punchbarrel Blog
Don't get me started about those stupid
subject: Not able to set file permissions using PERL
log4j and file permissions
Creating a file with proper permissions in linux - URGENT
Executing shell script
Chmod from Runtime.Exec
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015