Solved

Problems deleteing PERL created files.

Posted on 1998-06-05
4
180 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now