Solved

Problems deleteing PERL created files.

Posted on 1998-06-05
4
199 Views
Last Modified: 2010-03-04
Hi,
    I've written a PERL script that creates a file.  The problem is when I log onto my ISP through CuteFTP and try to delete this file it tells me it's forbidden.  I'm guessing the premissions are incorrect, however I wish to leave the file at 755.  I'm guessing also that it's because PERL is creating the file and not me so I don't own the file.  So how would I go about bestowing ownership of this file upon myself.
0
Comment
Question by:cide
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
tpryor earned 50 total points
ID: 1207658
Your assumptions are correct.

To change ownership in perl you would use the "chown" keyword ie:
chown $uid, $gid, $filename;

heres a subroutine that looks everything up for you then does the chown.

sub chown_by_name {
      local ($user, $pattern) = @_;
      chown((getpwnam($user)) [2, 3], glob($pattern));
}

&chown_by_name("fred", "*.c");

notice that this forces the group of each file to be the gid fetched from the passwd file.  An alternative is to pass a -1 for the gid, which leaves the group of the file unchanged.

on most systems you are not allowed to change ownership of a file unless you are the superuser, although you should be able to shange the group to any of your secondary groups.

I would suggest building a file management app in perl this way you could use perl to delete and update the permissions associated with the files created by perl via the web.  you could also password protect this app so only you could access this app.

GL
t
0
 

Author Comment

by:cide
ID: 1207659
So if I replaced fred with my user name it should have worked if I had access to chown right? Cause it didn't.
0
 
LVL 2

Expert Comment

by:tpryor
ID: 1207660
Thats correct.
If you make a simple perl/web interface to manage the files that perl creates for you would be your best bet.  I actually set the permissions to rwrwrw, and password protect the directory my perl created files live in then i just log in through ftp and im all set.
BTW, I dont think your host provider will give you superuser priv's.

sorry,

t
0
 

Author Comment

by:cide
ID: 1207661
I doubt that either! :P
ttyl.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question