Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Permissions on a file
May 16, 2008, 12:38 am
rate this thread
code (the last part of it)
$first_name = $FORM;
$last_name = $FORM;
open (example, ">remote.txt") || die ("Could not open file. $!");
print example "$first_name\n$last_name\n";
This bit causes errors...... chmod
print "<title> Processed</title>";
print "<h2>Commands $first_name $last_name - Sent to text file</h2>";
The problem is that I need to be able to delete this file remotely
using FTP and the script generate a new version every now and then. I
need teh script to make the file deleteable. How do I do this?
I tried chmod 0777,'remote.txt' and it spews out errors.
Re: Permissions on a file
You should always, yes always,
We have been through this once before
my $filename = 'remote.txt';
open my $EXAMPLE, '>', $filename
or die "Cannot open '$filename': $!";
print $EXAMPLE "$first_name\n$last_name\n";
It is crucial to check for errors on close on a filehandle opened for
close $EXAMPLE or die "Error closing '$filename': $!";
What errors does it cause?
chmod 0777, $filename
or die "Cannot chmod on '$filename': $!";
Have you read perldoc -f chmod and perldoc -f umask?
Don't be silly!
<h2>Commands $first_name $last_name - Sent to text file</h2>
Did you try looking at the error messages?
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
Re: Permissions on a file
I believe your problem is not a perl issue but a permission issue. The
script is running under a webmaster or other account and the file
created is owned by that creator, yet your ftp access is under a
different account name. If you have shell access, do a ls -l on that
directory to see who is the owner / group, that is who you need to be
to delete it. If you have ftp access as the server admin (versus the
webmaster) you can delete the file then (at least this has been my
I run into this all the time when a client gives me ftp access to
their website and gives me a webmaster account and wants me to update
their stuff that they posted using a different account. Interesting
thing I have seen is that I can most of the time rename what they have
then post my changed files, but can't delete what they have (or
Back on the perl issue, I did find away around this about 7 / 8 years
ago by using chown on the file after creating it to change who owned
the file from within a perl script.
- » Re: Need ideas on how to make this code faster than a speeding turtle
- — Previous thread in » PERL Discussions